V4.0 PC Resources folder - unable to 'listFilesRecursively'

After some time away, I’ve recently started a new Cocos2d 4.0 project. Despite my whole distaste for the all the resource file copying that goes on for PC ( V4.0 PC Resources folder ), I thought I would bite the bullet and keep an open mind and try to ‘go with the flow’ and use it in its default state for this project.
Here I am a few days later, and I think I might have already found a bug - or if not, I would love to know the ‘proper’ way of doing it without having to alter the Cocos2d engine code.
I simply wanted to get a list of files in a directory, which shouldn’t be all that difficult…but was having zero luck at all. (Using FileUtils::listFilesRecursively()) Listing the files wasn’t working at all, ‘FullPathForFilename()’, inside the CC2d engine function FileUtils::listFilesRecursively(), was always returning “” (none) for my directory. Even when I tried to simply list the contents of the ‘textures’ directory (which is a Cocos2d engine created directory!!), it would return ‘no directory found’. Keep in mind I have ALL my textures in there and have been using them completely successfully, but when I want to list the contents of the directory, it tells me that the directory does not exist.

So what I did was replace the first line of FileUtilsWin32::listFilesRecursively
“std::string fullpath = fullPathForFilename( dirPath );” with
“std::string fullpath = fullPathForDirectory( dirPath );”

Like magic, the directory is now ‘found’ by Cocos! So - I guess this is either a bug report, or if not - what should I be doing differently instead of having to alter the Cocos2d engine code to view the contents of the directory?

-HUGE fan of Cocos2d-X, just not the PC file resource copying part. (Again, in just a matter of days I’ve already had issues with changed resource files not properly getting copied, and other related issues, that NEVER happened with the old method, and didn’t require massive amounts of file copying just to run the app on PC.)

That is definitely a bug. It looks like this has been reported several times before, but the users reporting it didn’t realise how to fix it.


There is no need to create a new issue for it on there, but if you have the time and you’re comfortable with using github, then please create two pull request with the fix as well (one for v3 and another for v4).

Ah, cool, glad I was able to help find a bug! Unfortunately, I’m not very familiar with github…we would normally use SVN or Perforce in the past. I know I should learn github at some point, but right now I dont have a lot of time to learn how to use it.

No worries, I’ll see what I can do about creating those pull requests with the fix.

EDIT: Pull requests created for both v3 and v4, so hopefully they get merged in soon.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.