diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-14 18:00:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-14 18:00:20 +0300 |
commit | 5283a59db971ec2038149bf26ad9b3cbc4924449 (patch) | |
tree | c2f208b197a3726d6358ca707b64d01887bb6151 /src/utils/virtfs.cpp | |
parent | 59146da772888a295bbf8613f32bce5dd7bb00ab (diff) | |
download | manaverse-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.gz manaverse-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.bz2 manaverse-5283a59db971ec2038149bf26ad9b3cbc4924449.tar.xz manaverse-5283a59db971ec2038149bf26ad9b3cbc4924449.zip |
Add virtlist for file names enumeration in virtfs.
Diffstat (limited to 'src/utils/virtfs.cpp')
-rw-r--r-- | src/utils/virtfs.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/utils/virtfs.cpp b/src/utils/virtfs.cpp index 8b068f28e..6b87f87e9 100644 --- a/src/utils/virtfs.cpp +++ b/src/utils/virtfs.cpp @@ -23,6 +23,7 @@ #include "utils/checkutils.h" #include "utils/virtfile.h" #include "utils/virtfileprivate.h" +#include "utils/virtlist.h" #include <iostream> #include <unistd.h> @@ -85,9 +86,19 @@ namespace VirtFs return PHYSFS_exists(fname); } - char **enumerateFiles(const char *restrict const dir) + VirtList *enumerateFiles(const std::string &restrict dir) { - return PHYSFS_enumerateFiles(dir); + char** handle = PHYSFS_enumerateFiles(dir.c_str()); + VirtList *const files = new VirtList; + if (handle == nullptr) + return files; + for (char **i = handle; *i; i++) + { + std::string str = *i; + files->names.push_back(str); + } + PHYSFS_freeList(handle); + return files; } bool isDirectory(const char *restrict const fname) @@ -95,9 +106,9 @@ namespace VirtFs return PHYSFS_isDirectory(fname); } - void freeList(void *restrict const listVar) + void freeList(VirtList *restrict const handle) { - PHYSFS_freeList(listVar); + delete handle; } VirtFile *openRead(const char *restrict const filename) |