ADDED: IsFileHidden()

This commit is contained in:
Ray
2026-09-04 18:24:04 +02:00
parent 08a8068702
commit 1829f9282c
2 changed files with 8 additions and 7 deletions

View File

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

View File

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