(Android)How to determine whether path is directory |
(Android)How to determine whether path is directory |
ancientli
|
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? |
|||||||||||
|
(Android)How to determine whether path is directory |
Jonny D
|
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:
|
|||||||||||||
|
(Android)How to determine whether path is directory |
Jonny D
|
(not sure about asset path, because I used SDL_AndroidGetInternalStoragePath(), which returns something more like a config path)
Jonny D On Thu, Apr 7, 2016 at 10:29 AM, Jonathan Dearborn wrote:
|
|||||||||||||||
|
(Android)How to determine whether path is directory |
ancientli
|
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. |
|||||||||||
|