Fixed up the builtin

This commit is contained in:
ineed bots 2023-12-03 17:43:40 -06:00
parent 4843c61e2e
commit f0c95340bf
2 changed files with 6 additions and 5 deletions

View File

@ -89,13 +89,13 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
// close the file
```
* `<array of strings> FS_ListFiles(<folder string>, <recurse bool>(optional))` Returns a list of files inside of the folder given. Can recurse if set to `true`.
* `<array of strings> FS_ListFiles(<folder string>)` Returns a list of files inside of the folder given.
```gsc
files = FS_ListFiles("testfolder/");
for (i = 0; i < files.size; i++)
{
file - files[i]; // will be "testfolder/<filename>"
file = files[i]; // will be "testfolder/<filename>"
// do something with the filename
}

View File

@ -36,7 +36,7 @@ namespace fileio
{
if (fpath.empty())
{
return false;
return true;
}
constexpr static std::array bad_strings { R"(..)", R"(../)", R"(..\)" };
@ -404,7 +404,8 @@ namespace fileio
gsc::function::add("fs_listfiles", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
std::string dir = game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER);
auto fpath = build_base_path(dir);
int numfiles;
auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles);
@ -412,7 +413,7 @@ namespace fileio
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
for (int i = 0; i < numfiles; i++)
{
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, files[i]);
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, (dir + "/" + files[i]).c_str());
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
}