diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-01 00:09:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-01 00:09:28 +0300 |
commit | af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a (patch) | |
tree | 0074b8eb5fea7f48f44dd81bc5089316e81aafd0 /src/fs | |
parent | db31c2f832dd4067e4670dd469fe3b696188576b (diff) | |
download | plus-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.gz plus-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.bz2 plus-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.xz plus-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.zip |
Impliment some functions in VirtFs with physfs disabled.
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/virtfs.cpp | 13 | ||||
-rw-r--r-- | src/fs/virtfsdir.cpp | 10 | ||||
-rw-r--r-- | src/fs/virtfsdir.h | 4 | ||||
-rw-r--r-- | src/fs/virtfszip.cpp | 9 | ||||
-rw-r--r-- | src/fs/virtfszip.h | 4 |
5 files changed, 34 insertions, 6 deletions
diff --git a/src/fs/virtfs.cpp b/src/fs/virtfs.cpp index 3ba214dc7..69f379a08 100644 --- a/src/fs/virtfs.cpp +++ b/src/fs/virtfs.cpp @@ -87,12 +87,23 @@ namespace VirtFs bool exists(const std::string &restrict name) { +#ifdef USE_PHYSFS return VirtFsPhys::exists(name); +#else // USE_PHYSFS + return VirtFsDir::exists(name) || VirtFsZip::exists(name); +#endif // USE_PHYSFS } - VirtList *enumerateFiles(const std::string &restrict dir) + VirtList *enumerateFiles(const std::string &restrict dirName) { +#ifdef USE_PHYSFS return VirtFsPhys::enumerateFiles(dir); +#else // USE_PHYSFS + VirtList *const list = new VirtList; + VirtFsDir::enumerateFiles(dirName, list); + VirtFsZip::enumerateFiles(dirName, list); + return list; +#endif // USE_PHYSFS } bool isDirectory(const std::string &restrict name) diff --git a/src/fs/virtfsdir.cpp b/src/fs/virtfsdir.cpp index 6673072aa..cb512f2ca 100644 --- a/src/fs/virtfsdir.cpp +++ b/src/fs/virtfsdir.cpp @@ -338,10 +338,16 @@ namespace VirtFsDir return false; } - VirtList *enumerateFiles(std::string dirName) + VirtList *enumerateFiles(const std::string &dirName) { - prepareFsPath(dirName); VirtList *const list = new VirtList; + return enumerateFiles(dirName, list); + } + + VirtList *enumerateFiles(std::string dirName, + VirtList *const list) + { + prepareFsPath(dirName); if (checkPath(dirName) == false) { reportAlways("VirtFsDir::enumerateFiles invalid path: %s", diff --git a/src/fs/virtfsdir.h b/src/fs/virtfsdir.h index 8ea825d82..0ec2f466d 100644 --- a/src/fs/virtfsdir.h +++ b/src/fs/virtfsdir.h @@ -52,7 +52,9 @@ namespace VirtFsDir void deinit(); std::vector<VirtDirEntry*> &getEntries(); bool exists(std::string name); - VirtList *enumerateFiles(std::string dir) RETURNS_NONNULL; + VirtList *enumerateFiles(const std::string &dirName) RETURNS_NONNULL; + VirtList *enumerateFiles(std::string dirName, + VirtList *const list) RETURNS_NONNULL; bool isDirectory(std::string dirName); bool isSymbolicLink(std::string name); void freeList(VirtList *restrict const handle); diff --git a/src/fs/virtfszip.cpp b/src/fs/virtfszip.cpp index dc8223b6f..538eb7513 100644 --- a/src/fs/virtfszip.cpp +++ b/src/fs/virtfszip.cpp @@ -261,7 +261,14 @@ namespace VirtFsZip return false; } - VirtList *enumerateFiles(std::string dirName) + VirtList *enumerateFiles(const std::string &dirName) + { + VirtList *const list = new VirtList; + return enumerateFiles(dirName, list); + } + + VirtList *enumerateFiles(std::string dirName, + VirtList *const list) { prepareFsPath(dirName); VirtList *const list = new VirtList; diff --git a/src/fs/virtfszip.h b/src/fs/virtfszip.h index d66ce7ee8..fd7a0568b 100644 --- a/src/fs/virtfszip.h +++ b/src/fs/virtfszip.h @@ -50,7 +50,9 @@ namespace VirtFsZip void deinit(); std::vector<VirtZipEntry*> &getEntries(); bool exists(std::string name); - VirtList *enumerateFiles(std::string dir) RETURNS_NONNULL; + VirtList *enumerateFiles(const std::string &dirName) RETURNS_NONNULL; + VirtList *enumerateFiles(std::string dirName, + VirtList *const list) RETURNS_NONNULL; bool isDirectory(std::string dirName); bool isSymbolicLink(std::string name); void freeList(VirtList *restrict const handle); |