From f0c95340bf5de8412cfd9fddd77f150d3ee52e3a Mon Sep 17 00:00:00 2001 From: ineed bots Date: Sun, 3 Dec 2023 17:43:40 -0600 Subject: [PATCH] Fixed up the builtin --- README.md | 4 ++-- src/component/fileio.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d950b41..0b8e11a 100644 --- a/README.md +++ b/README.md @@ -89,13 +89,13 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio // close the file ``` -* ` FS_ListFiles(, (optional))` Returns a list of files inside of the folder given. Can recurse if set to `true`. +* ` FS_ListFiles()` 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/" + file = files[i]; // will be "testfolder/" // do something with the filename } diff --git a/src/component/fileio.cpp b/src/component/fileio.cpp index 8fee060..f0fb69f 100644 --- a/src/component/fileio.cpp +++ b/src/component/fileio.cpp @@ -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); }