Create path_is_valid

This commit is contained in:
twinaphex 2015-09-21 22:46:27 +02:00
parent 77d99395a2
commit 9d67d48036
2 changed files with 28 additions and 3 deletions

View File

@ -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

View File

@ -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