classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view



The spec shows that there is only a function for iterating over files, not directories. This either means that the developers using the NDK can't query the asset manager for directories; at least not on my device. Or that it only works on some devices (not on 8.0.0 s7 edge). I'd recommend adding AAssetDir_getNextFolderName, requiring AAssetDir_getNextFileName to display directories as well as assets or providing a function to loop over all files in the assets dir (nested).

	AAssetManager *assetManager = ((android_app*)param)->activity->assetManager;
	AAssetDir *dir = AAssetManager_openDir(assetManager, path);


	const char *name = nullptr;

	while ((name = AAssetDir_getNextFileName(dir)) != nullptr) {
		Log::println(String("res/") + name);


Doesn't do anything for path = "" or "res" (assets/res; a directory with only directories), but when I pass in a directory with files "res/shaders" (assets/res/shaders) it does work.

AssetDir supports this, why is this removed by AAssetManager?

I posted this issue on Github too; which got the following response:

"this needs some digging into the history and not sure what will be outcome either:

// Find the next regular file; explicitly don't report directories even if the
// underlying implementation changes to report them.  At that point we can add
// a more general iterator to this native interface set if appropriate.
   while ((index < max) && (assetDir->mAssetDir->getFileType(index) != kFileTypeRegular)) {

How about post this question to https://groups.google.com/forum/#!forum/android-ndk?"

You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/4ce12096-472d-4ca3-b2ab-64a1232d6efc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.