Browse Source

Merge branch 'master' of https://github.com/raysan5/raylib

pull/4325/head
Ray 4 months ago
parent
commit
186787e311
6 changed files with 39 additions and 9 deletions
  1. +1
    -1
      parser/output/raylib_api.json
  2. +1
    -1
      parser/output/raylib_api.lua
  3. +1
    -1
      parser/output/raylib_api.txt
  4. +1
    -1
      parser/output/raylib_api.xml
  5. +1
    -1
      src/raylib.h
  6. +34
    -4
      src/rcore.c

+ 1
- 1
parser/output/raylib_api.json View File

@ -4523,7 +4523,7 @@
},
{
"name": "LoadDirectoryFilesEx",
"description": "Load directory filepaths with extension filtering and recursive directory scan",
"description": "Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result",
"returnType": "FilePathList",
"params": [
{

+ 1
- 1
parser/output/raylib_api.lua View File

@ -4076,7 +4076,7 @@ return {
},
{
name = "LoadDirectoryFilesEx",
description = "Load directory filepaths with extension filtering and recursive directory scan",
description = "Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result",
returnType = "FilePathList",
params = {
{type = "const char *", name = "basePath"},

+ 1
- 1
parser/output/raylib_api.txt View File

@ -1722,7 +1722,7 @@ Function 137: LoadDirectoryFiles() (1 input parameters)
Function 138: LoadDirectoryFilesEx() (3 input parameters)
Name: LoadDirectoryFilesEx
Return type: FilePathList
Description: Load directory filepaths with extension filtering and recursive directory scan
Description: Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result
Param[1]: basePath (type: const char *)
Param[2]: filter (type: const char *)
Param[3]: scanSubdirs (type: bool)

+ 1
- 1
parser/output/raylib_api.xml View File

@ -1081,7 +1081,7 @@
<Function name="LoadDirectoryFiles" retType="FilePathList" paramCount="1" desc="Load directory filepaths">
<Param type="const char *" name="dirPath" desc="" />
</Function>
<Function name="LoadDirectoryFilesEx" retType="FilePathList" paramCount="3" desc="Load directory filepaths with extension filtering and recursive directory scan">
<Function name="LoadDirectoryFilesEx" retType="FilePathList" paramCount="3" desc="Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result">
<Param type="const char *" name="basePath" desc="" />
<Param type="const char *" name="filter" desc="" />
<Param type="bool" name="scanSubdirs" desc="" />

+ 1
- 1
src/raylib.h View File

@ -1126,7 +1126,7 @@ RLAPI bool ChangeDirectory(const char *dir); // Change work
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 FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result
RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths

+ 34
- 4
src/rcore.c View File

@ -251,6 +251,10 @@ unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
#define MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record
#endif
#ifndef FILTER_FOLDER
#define FILTER_FOLDER "/DIR" // Filter string used in ScanDirectoryFiles, ScanDirectoryFilesRecursively and LoadDirectoryFilesEx to include directories in the result array
#endif
// Flags operation macros
#define FLAG_SET(n, f) ((n) |= (f))
#define FLAG_CLEAR(n, f) ((n) &= ~(f))
@ -3339,10 +3343,21 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
if (filter != NULL)
{
if (IsFileExtension(path, filter))
if (IsPathFile(path))
{
strcpy(files->paths[files->count], path);
files->count++;
if (IsFileExtension(path, filter))
{
strcpy(files->paths[files->count], path);
files->count++;
}
}
else
{
if (TextFindIndex(filter, FILTER_FOLDER) >= 0)
{
strcpy(files->paths[files->count], path);
files->count++;
}
}
}
else
@ -3402,7 +3417,22 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi
break;
}
}
else ScanDirectoryFilesRecursively(path, files, filter);
else
{
if (filter != NULL && TextFindIndex(filter, FILTER_FOLDER) >= 0)
{
strcpy(files->paths[files->count], path);
files->count++;
}
if (files->count >= files->capacity)
{
TRACELOG(LOG_WARNING, "FILEIO: Maximum filepath scan capacity reached (%i files)", files->capacity);
break;
}
ScanDirectoryFilesRecursively(path, files, filter);
}
}
}

Loading…
Cancel
Save