Merge branch 'raysan5:master' into master
This commit is contained in:
commit
614eae7c5a
|
|
@ -4499,6 +4499,17 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "IsFileNameValid",
|
||||
"description": "Check if fileName is valid for the platform/OS",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LoadDirectoryFiles",
|
||||
"description": "Load directory filepaths",
|
||||
|
|
|
|||
|
|
@ -4058,6 +4058,14 @@ return {
|
|||
{type = "const char *", name = "path"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "IsFileNameValid",
|
||||
description = "Check if fileName is valid for the platform/OS",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "LoadDirectoryFiles",
|
||||
description = "Load directory filepaths",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -670,7 +670,7 @@
|
|||
<Param type="unsigned int" name="frames" desc="" />
|
||||
</Callback>
|
||||
</Callbacks>
|
||||
<Functions count="562">
|
||||
<Functions count="563">
|
||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||
<Param type="int" name="width" desc="" />
|
||||
<Param type="int" name="height" desc="" />
|
||||
|
|
@ -1075,6 +1075,9 @@
|
|||
<Function name="IsPathFile" retType="bool" paramCount="1" desc="Check if a given path is a file or a directory">
|
||||
<Param type="const char *" name="path" desc="" />
|
||||
</Function>
|
||||
<Function name="IsFileNameValid" retType="bool" paramCount="1" desc="Check if fileName is valid for the platform/OS">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadDirectoryFiles" retType="FilePathList" paramCount="1" desc="Load directory filepaths">
|
||||
<Param type="const char *" name="dirPath" desc="" />
|
||||
</Function>
|
||||
|
|
|
|||
|
|
@ -1124,6 +1124,7 @@ RLAPI const char *GetWorkingDirectory(void); // Get current
|
|||
RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)
|
||||
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success
|
||||
RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory
|
||||
RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS
|
||||
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths
|
||||
RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan
|
||||
RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
|
||||
|
|
|
|||
58
src/rcore.c
58
src/rcore.c
|
|
@ -2244,6 +2244,64 @@ bool IsPathFile(const char *path)
|
|||
return S_ISREG(result.st_mode);
|
||||
}
|
||||
|
||||
// Check if fileName is valid for the platform/OS
|
||||
bool IsFileNameValid(const char *fileName)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
if ((fileName != NULL) && (fileName[0] != '\0'))
|
||||
{
|
||||
int length = strlen(fileName);
|
||||
bool allPeriods = true;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
// Check invalid characters
|
||||
if ((fileName[i] == '<') ||
|
||||
(fileName[i] == '>') ||
|
||||
(fileName[i] == ':') ||
|
||||
(fileName[i] == '\"') ||
|
||||
(fileName[i] == '/') ||
|
||||
(fileName[i] == '\\') ||
|
||||
(fileName[i] == '|') ||
|
||||
(fileName[i] == '?') ||
|
||||
(fileName[i] == '*')) { valid = false; break; }
|
||||
|
||||
// Check non-glyph characters
|
||||
if ((unsigned char)fileName[i] < 32) { valid = false; break; }
|
||||
|
||||
// TODO: Check trailing periods/spaces?
|
||||
|
||||
// Check if filename is not all periods
|
||||
if (fileName[i] != '.') allPeriods = false;
|
||||
}
|
||||
|
||||
if (allPeriods) valid = false;
|
||||
|
||||
/*
|
||||
if (valid)
|
||||
{
|
||||
// Check invalid DOS names
|
||||
if (length >= 3)
|
||||
{
|
||||
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'N')) || // CON
|
||||
((fileName[0] == 'P') && (fileName[1] == 'R') && (fileName[2] == 'N')) || // PRN
|
||||
((fileName[0] == 'A') && (fileName[1] == 'U') && (fileName[2] == 'X')) || // AUX
|
||||
((fileName[0] == 'N') && (fileName[1] == 'U') && (fileName[2] == 'L'))) valid = false; // NUL
|
||||
}
|
||||
|
||||
if (length >= 4)
|
||||
{
|
||||
if (((fileName[0] == 'C') && (fileName[1] == 'O') && (fileName[2] == 'M') && ((fileName[3] >= '0') && (fileName[3] <= '9'))) || // COM0-9
|
||||
((fileName[0] == 'L') && (fileName[1] == 'P') && (fileName[2] == 'T') && ((fileName[3] >= '0') && (fileName[3] <= '9')))) valid = false; // LPT0-9
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
// Check if a file has been dropped into window
|
||||
bool IsFileDropped(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user