Reputation: 1013
I want to list folders and files inside Resources folder from android and ios. I've been able to do so by 'opendir' and 'readdir' from 'dirent.h' but only in ios emulator. It doesn't work in android. Did anyone face such problem? Thanks.
Upvotes: 2
Views: 1616
Reputation: 1200
One way could be to mantain a file containing a list of all the files in the resource directory along with their hierarchy.
For example, say you have a directory hirearchy as:
Resources/
folder1/
file1.jpeg
file2.jpeg
folder2/
file1.jpeg
file2.jpeg
Then you can mantain a file containing the paths as:
in resource_paths.txt
folder1/file1.jpeg
folder1/file2.jpeg
folder2/file1.jpeg
folder2/file2.jpeg
Then search in the file for list of directories/files :)
Upvotes: 3
Reputation: 8006
AFAIK, this can't be done on Android using only C++. Since you already have the iOS part figured out, you shuould wrap the iOS specific code (#include
s too) in
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
...
#endif
The same will aply for Android only code (`CC_PLATFORM_ANDROID') - to achieve what you want you have to write a JNI call in order to call a Java function from C++. Assuming that you want to just dump this data to a log, everything should be pretty straightforward. I don't have a link at hand, but there was an extensive topic about opening URLs which coverd the JNI tutorial and it shouldn't be hard to find.
Upvotes: 5