(Android)How to determine whether path is directory

I want to add API to SDL.

SDL_bool SDL_IsDirectory(const char* dir)

SDL_bool SDL_IsFile(const char* file)

On android, SDL_IsFile uses AssetManager.open(), if success, it is true. But
to SDL_IsDirectory, I cannot find proper method. I try to use
AssetManager.list(), it too spend CPU, and have to give up.

Is there an effective method to determine path is directory?

I want to add API to SDL.

SDL_bool SDL_IsDirectory(const char* dir)

SDL_bool SDL_IsFile(const char* file)

On android, SDL_IsFile uses AssetManager.open(), if success, it is true. But
to SDL_IsDirectory, I cannot find proper method. I try to use
AssetManager.list(), it too spend CPU, and have to give up.

Is there an effective method to determine the path is directory?

I think you can use stat(), but you have to use it on the actual file path
because it won’t do SDL’s asset path magic:

bool ioIsDir(const char* filename)
{
struct stat status;
stat(filename, &status);

return (status.st_mode & S_IFDIR);

}

Called as so:
snprintf(mybuffer, mybuffer_size, “%s/%s”,
SDL_AndroidGetInternalStoragePath(), “some_directory”);
if(ioIsDir(mybuffer))

Jonny DOn Thu, Apr 7, 2016 at 10:17 AM, ancientcc wrote:

I want to add API to SDL.

SDL_bool SDL_IsDirectory(const char* dir)

SDL_bool SDL_IsFile(const char* file)

On android, SDL_IsFile uses AssetManager.open(), if success, it is true.
But to SDL_IsDirectory, I cannot find proper method. I try to use
AssetManager.list(), it too spend CPU, and have to give up.

Is there an effective method to determine the path is directory?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

(not sure about asset path, because I used SDL_
AndroidGetInternalStoragePath(), which returns something more like a config
path)

Jonny DOn Thu, Apr 7, 2016 at 10:29 AM, Jonathan Dearborn <@Jonathan_Dearborn> wrote:

I think you can use stat(), but you have to use it on the actual file path
because it won’t do SDL’s asset path magic:

bool ioIsDir(const char* filename)
{
struct stat status;
stat(filename, &status);

return (status.st_mode & S_IFDIR);

}

Called as so:
snprintf(mybuffer, mybuffer_size, “%s/%s”,
SDL_AndroidGetInternalStoragePath(), “some_directory”);
if(ioIsDir(mybuffer))

Jonny D

On Thu, Apr 7, 2016 at 10:17 AM, ancientcc wrote:

I want to add API to SDL.

SDL_bool SDL_IsDirectory(const char* dir)

SDL_bool SDL_IsFile(const char* file)

On android, SDL_IsFile uses AssetManager.open(), if success, it is true.
But to SDL_IsDirectory, I cannot find proper method. I try to use
AssetManager.list(), it too spend CPU, and have to give up.

Is there an effective method to determine the path is directory?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If access directory/file that not app?asset, use stat is OK. But if apply to asset, stat will fail.

The directory is on asset.