mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-19 21:22:54 +00:00
add fs_listfiles
This commit is contained in:
parent
4963a9180a
commit
b79b776f63
@ -401,6 +401,23 @@ namespace fileio
|
||||
|
||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
|
||||
});
|
||||
|
||||
gsc::function::add("fs_listfiles", []()
|
||||
{
|
||||
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
|
||||
|
||||
int numfiles;
|
||||
auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles);
|
||||
|
||||
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
|
||||
for (int i = 0; i < numfiles; i++)
|
||||
{
|
||||
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, files[i]);
|
||||
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||
}
|
||||
|
||||
game::FS_FreeFileList(files);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,6 +231,21 @@ namespace game
|
||||
*cmd_functions = newCmd;
|
||||
}
|
||||
|
||||
// restored
|
||||
const char** FS_ListFiles(const char* path, const char* extension, FsListBehavior_e behavior, int* numfiles)
|
||||
{
|
||||
return FS_ListFilteredFiles(*fs_searchpaths, path, extension, nullptr, behavior, numfiles);
|
||||
}
|
||||
|
||||
// restored
|
||||
void FS_FreeFileList(const char** list)
|
||||
{
|
||||
if ( list )
|
||||
{
|
||||
Hunk_UserDestroy((HunkUser*)*(list - 1));
|
||||
}
|
||||
}
|
||||
|
||||
// restored
|
||||
void Sys_EnterCriticalSection(CriticalSection critSect)
|
||||
{
|
||||
|
@ -78,6 +78,9 @@ namespace game
|
||||
void Sys_EnterCriticalSection(CriticalSection critSect);
|
||||
void Sys_LeaveCriticalSection(CriticalSection critSect);
|
||||
|
||||
const char** FS_ListFiles(const char* path, const char* extension, FsListBehavior_e behavior, int* numfiles);
|
||||
void FS_FreeFileList(const char** list);
|
||||
|
||||
// Variables
|
||||
WEAK symbol<CRITICAL_SECTION> s_criticalSection{ 0x0, 0x2298D08 };
|
||||
WEAK symbol<HunkUser*> g_DebugHunkUser{ 0x0, 0x212B2EC };
|
||||
|
Loading…
x
Reference in New Issue
Block a user