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 | |
parent | db31c2f832dd4067e4670dd469fe3b696188576b (diff) | |
download | manaverse-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.gz manaverse-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.bz2 manaverse-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.tar.xz manaverse-af8edd3f2f53cb2ece9a7b1f6a62bd5e7ce57a9a.zip |
Impliment some functions in VirtFs with physfs disabled.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-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 |
6 files changed, 36 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 71d5c3c87..31d78afe7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -582,8 +582,6 @@ BASE_SRC += events/actionevent.h \ utils/stringvector.h \ utils/timer.cpp \ utils/timer.h \ - fs/virtdirentry.cpp \ - fs/virtdirentry.h \ fs/virtfile.cpp \ fs/virtfile.h \ fs/virtfileprivate.cpp \ @@ -834,6 +832,8 @@ BASE_SRC += \ fs/virtfsphys.h else BASE_SRC += \ + fs/virtdirentry.cpp \ + fs/virtdirentry.h \ fs/virtfsdir.cpp \ fs/virtfsdir.h \ fs/virtfszip.cpp \ 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); |