mirror of
https://github.com/raysan5/raylib.git
synced 2026-09-14 01:50:50 +00:00
ADDED: IsFileHidden()
This commit is contained in:
@@ -1149,6 +1149,7 @@ RLAPI int FileTextFindIndex(const char *fileName, const char *search); // Find t
|
||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if directory path exists
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (recommended include point: .png, .wav)
|
||||
RLAPI bool IsFileHidden(const char *filePath); // Check if file path (file or directory) is hidden by OS
|
||||
RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
|
||||
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||
|
||||
14
src/rcore.c
14
src/rcore.c
@@ -2413,20 +2413,20 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if a provided file path (or directory) is hidden by OS
|
||||
bool IsFileHidden(const char *path)
|
||||
// Check if file path (file or directory) is hidden by OS
|
||||
bool IsFileHidden(const char *filePath)
|
||||
{
|
||||
bool result = false;
|
||||
#if defined(_WIN32)
|
||||
unsigned long attribs = GetFileAttributesA(path);
|
||||
unsigned long attribs = GetFileAttributesA(filePath);
|
||||
|
||||
// Check !INVALID_FILE_ATTRIBUTES and FILE_ATTRIBUTE_HIDDEN
|
||||
if ((attribs != -1) && ((attrs & 0x2UL) != 0)) result = true;
|
||||
if ((attribs != -1) && ((attribs & 0x2UL) != 0)) result = true;
|
||||
#else
|
||||
const char *base = strrchr(path, '/');
|
||||
base = (base? base + 1 : path);
|
||||
const char *basePath = strrchr(filePath, '/');
|
||||
basePath = (basePath? basePath + 1 : filePath);
|
||||
|
||||
if ((base[0] == '.') && (strcmp(base, ".") != 0) && (strcmp(base, "..") != 0)) result = true;
|
||||
if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user