Can I create a sprite when the path is a symbolic link (shortcut)?

I have some key folders in my game (images, photo sets, etc), and then let the users select subfolders under those. I’d like to add the ability to pick up shortcuts to folders.

UPDATE: even if I hard-code the full path, Sprite::create(filename) is failing. For example, I tried this:
d:\testing1/psf2024/player_photo_sets/players/Roger_Staubach.jpg

where “players” is a shortcut to an actual folder, and Sprite::create() returns nullptr. If I create a folder named “players” and put the photo there, it works - just not if it’s a shortcut.


Separately, if I can get this to work, then I’d like to know if I can locate such shortcuts, but only if they’ll actually work for sprites.

  std::vector<std::string> vector = FileUtils::getInstance()->listFiles(searchPath);
  string filename;
  bool addIt;

  searchPath = appendSlash(searchPath);

  for (int i=0; i<vector.size(); i++)
  {
    filename = vector.at(i);
    addIt = FileUtils::getInstance()->isDirectoryExist(filename);
    ... etc
  }

“isDirectoryExist(filename)” fails on shortcuts or symbolic links, and I can’t find another FileUtils function that works for that. Is there something available?

thanks!

I found the problem in CCFileUtile-win32.cpp, but I haven’t been able to fix it. The method is

FileUtils::Status FileUtilsWin32::getContents(const std::string& filename, ResizableBuffer* buffer)
{
    if (filename.empty())
        return FileUtils::Status::NotExists;

    // read the file from hardware
    std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename);

    HANDLE fileHandle = ::CreateFile(StringUtf8ToWideChar(fullPath).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, nullptr);
    
    if (fileHandle == INVALID_HANDLE_VALUE)
        return FileUtils::Status::OpenFailed;

	DWORD hi;
    auto size = ::GetFileSize(fileHandle, &hi);
	if (hi > 0)
	{
		::CloseHandle(fileHandle);
		return FileUtils::Status::TooLarge;
	}
    // don't read file content if it is empty
    if (size == 0)
    {
        ::CloseHandle(fileHandle);
        return FileUtils::Status::OK;
    }

    buffer->resize(size);
    DWORD sizeRead = 0;
    BOOL successed = ::ReadFile(fileHandle, buffer->buffer(), size, &sizeRead, nullptr);
    ::CloseHandle(fileHandle);

    if (!successed) {
		CCLOG("Get data from file(%s) failed, error code is %s", filename.data(), std::to_string(::GetLastError()).data());
		buffer->resize(sizeRead);
		return FileUtils::Status::ReadFailed;
    }
    return FileUtils::Status::OK;
}

and the problem is that ::CreateFile() returns INVALID_HANDLE_VALUE. I’ve tried a few things with the arguments, but nothing has helped.

Actually, it may be a Windows problem. I’ve googled and tried various things even in the Windows browser, and it won’t open a file that is in a shortcut folder. :frowning: