fixed file_exists and dir_exists
This commit is contained in:
parent
965c784e37
commit
0adea8c52c
@ -12,13 +12,13 @@ bool dir_exists(const char* path){
|
|||||||
#if KFS_USE_WINDOWS_H
|
#if KFS_USE_WINDOWS_H
|
||||||
DWORD dwAttrib = GetFileAttributes(path);
|
DWORD dwAttrib = GetFileAttributes(path);
|
||||||
return (bool)(
|
return (bool)(
|
||||||
(dwAttrib != INVALID_FILE_ATTRIBUTES) & // file exists
|
(dwAttrib != INVALID_FILE_ATTRIBUTES) && // file exists
|
||||||
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); // file is a directory
|
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); // file is a directory
|
||||||
#else
|
#else
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
i32 rez=stat(path, &stats);
|
i32 rez=stat(path, &stats);
|
||||||
return (bool)(
|
return (bool)(
|
||||||
(rez!=-1) & // file exists
|
(rez!=-1) && // file exists
|
||||||
(S_ISDIR(stats.st_mode))); // file is a directory
|
(S_ISDIR(stats.st_mode))); // file is a directory
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,13 +15,13 @@ bool file_exists(const char* path){
|
|||||||
#if KFS_USE_WINDOWS_H
|
#if KFS_USE_WINDOWS_H
|
||||||
DWORD dwAttrib = GetFileAttributes(path);
|
DWORD dwAttrib = GetFileAttributes(path);
|
||||||
return (bool)(
|
return (bool)(
|
||||||
(dwAttrib != INVALID_FILE_ATTRIBUTES) & // file exists
|
(dwAttrib != INVALID_FILE_ATTRIBUTES) && // file exists
|
||||||
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); // file is not directory
|
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); // file is not directory
|
||||||
#else
|
#else
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
i32 rez=stat(path, &stats);
|
i32 rez=stat(path, &stats);
|
||||||
return (bool)(
|
return (bool)(
|
||||||
(rez!=-1) & // file exists
|
(rez!=-1) && // file exists
|
||||||
!(S_ISDIR(stats.st_mode))); // file is not directory
|
!(S_ISDIR(stats.st_mode))); // file is not directory
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user