diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 79eda2fcc0..dc1dbf3ad9 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -172,15 +172,15 @@ bool path_is_compressed_file(const char* path) */ bool path_is_directory(const char *path) { -#if defined(VITA) +#if defined(VITA) || defined(PSP) SceIoStat buf; if (sceIoGetstat(path, &buf) < 0) - return -1; + return false; return PSP2_S_ISDIR(buf.st_mode); #elif defined(__CELLOS_LV2__) CellFsStat buf; if (cellFsStat(path, &buf) < 0) - return -1; + return false; return ((buf.st_mode & S_IFMT) == S_IFDIR); #elif defined(_WIN32) DWORD ret = GetFileAttributes(path); @@ -194,6 +194,29 @@ bool path_is_directory(const char *path) #endif } +bool path_is_valid(const char *path) +{ +#if defined(VITA) || defined(PSP) + SceIoStat buf; + if (sceIoGetstat(path, &buf) < 0) + return false; + return true; +#elif defined(__CELLOS_LV2__) + CellFsStat buf; + if (cellFsStat(path, &buf) < 0) + return false; + return true; +#elif defined(_WIN32) + DWORD ret = GetFileAttributes(path); + return (ret != INVALID_FILE_ATTRIBUTES); +#else + struct stat buf; + if (stat(path, &buf) < 0) + return false; + return true; +#endif +} + /** * path_file_exists: * @path : path diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 01bf401dd1..0d00177e28 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -84,6 +84,8 @@ bool path_contains_compressed_file(const char *path); */ bool path_is_directory(const char *path); +bool path_is_valid(const char *path); + /** * path_file_exists: * @path : path