diff options
| author | jussi | 2022-11-27 16:25:25 +0200 |
|---|---|---|
| committer | jussi | 2022-11-27 16:25:25 +0200 |
| commit | 08ef5b435273eaa3de860eac1c031219cd815587 (patch) | |
| tree | 921570cddf499c1ac5f10b55342300c190edac55 /src | |
| parent | deda5fb9170295133444809618835e8b9aa61512 (diff) | |
| download | reilua-enhanced-08ef5b435273eaa3de860eac1c031219cd815587.tar.gz reilua-enhanced-08ef5b435273eaa3de860eac1c031219cd815587.tar.bz2 reilua-enhanced-08ef5b435273eaa3de860eac1c031219cd815587.zip | |
RL_LoadDirectoryFilesEx and separate option for doc_parser.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 27 | ||||
| -rw-r--r-- | src/lua_core.c | 1 |
2 files changed, 28 insertions, 0 deletions
@@ -2199,6 +2199,33 @@ int lcoreLoadDirectoryFiles( lua_State *L ) { } /* +> fileNames = RL_LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs ) + +Load directory filepaths with extension filtering and recursive directory scan + +- Failure return false +- Success return string{} +*/ +int lcoreLoadDirectoryFilesEx( lua_State *L ) { + if ( !lua_isstring( L, -3 ) || !lua_isstring( L, -2 ) || !lua_isboolean( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_LoadDirectoryFilesEx( string dirPath )" ); + lua_pushboolean( L, false ); + return 1; + } + FilePathList files = LoadDirectoryFilesEx( lua_tostring( L, -3 ), lua_tostring( L, -2 ), lua_toboolean( L, -1 ) ); + + lua_createtable( L, files.count, 0 ); + + for ( int i = 0; i < files.count; ++i ) { + lua_pushstring( L, files.paths[i] ); + lua_rawseti( L, -2, i+1 ); + } + UnloadDirectoryFiles( files ); + + return 1; +} + +/* > success = RL_ChangeDirectory( string directory ) Change working directory, return true on success diff --git a/src/lua_core.c b/src/lua_core.c index 1d46440..defd8f2 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -748,6 +748,7 @@ void luaRegister() { lua_register( L, "RL_GetPrevDirectoryPath", lcoreGetPrevDirectoryPath ); lua_register( L, "RL_GetWorkingDirectory", lcoreGetWorkingDirectory ); lua_register( L, "RL_LoadDirectoryFiles", lcoreLoadDirectoryFiles ); + lua_register( L, "RL_LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx ); lua_register( L, "RL_ChangeDirectory", lcoreChangeDirectory ); lua_register( L, "RL_IsFileDropped", lcoreIsFileDropped ); lua_register( L, "RL_LoadDroppedFiles", lcoreLoadDroppedFiles ); |
