diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 56 | ||||
-rw-r--r-- | src/fs/virtfs.cpp | 30 | ||||
-rw-r--r-- | src/fs/virtfstools.cpp | 20 | ||||
-rw-r--r-- | src/fs/virtfstools.h | 8 |
5 files changed, 84 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5eb5c2c91..a7e2c3c28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,7 @@ IF (ENABLE_TMWA) SET(FLAGS "${FLAGS} -DTMWA_SUPPORT=1") ENDIF() -SET(FLAGS "${FLAGS} -DENABLE_LIBXML -DENABLE_ASSERTS") +SET(FLAGS "${FLAGS} -DENABLE_LIBXML -DENABLE_ASSERTS -DUSE_PHYSFS") IF (CMAKE_BUILD_TYPE) STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) diff --git a/src/Makefile.am b/src/Makefile.am index 57b264163..71d5c3c87 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,6 +76,11 @@ dyecmd_CXXFLAGS += -DUSE_OPENGL manaplus_CXXFLAGS += -DUSE_OPENGL endif +if USE_PHYSFS +dyecmd_CXXFLAGS += -DUSE_PHYSFS +manaplus_CXXFLAGS += -DUSE_PHYSFS +endif + if ENABLE_MEM_DEBUG dyecmd_CXXFLAGS += -DENABLE_MEM_DEBUG -DDEBUG_DUMP_LEAKS manaplus_CXXFLAGS += -DENABLE_MEM_DEBUG -DDEBUG_DUMP_LEAKS @@ -551,27 +556,15 @@ BASE_SRC += events/actionevent.h \ utils/perfomance.cpp \ utils/perfomance.h \ utils/debugmemoryobject.h \ - fs/virtfsdir.cpp \ - fs/virtfsdir.h \ fs/virtfsfuncs.h \ - fs/virtfsphys.cpp \ - fs/virtfsphys.h \ fs/virtfsrwops.cpp \ fs/virtfsrwops.h \ fs/virtfstools.cpp \ fs/virtfstools.h \ - fs/virtfszip.cpp \ - fs/virtfszip.h \ fs/virtlist.cpp \ fs/virtlist.h \ - fs/virtzipentry.cpp \ - fs/virtzipentry.h \ fs/virtfs.cpp \ fs/virtfs.h \ - fs/zip.cpp \ - fs/zip.h \ - fs/ziplocalheader.cpp \ - fs/ziplocalheader.h \ utils/process.cpp \ utils/process.h \ utils/sdl2helper.cpp \ @@ -835,6 +828,24 @@ BASE_SRC += events/actionevent.h \ resources/memorymanager.h \ winver.h +if USE_PHYSFS +BASE_SRC += \ + fs/virtfsphys.cpp \ + fs/virtfsphys.h +else +BASE_SRC += \ + fs/virtfsdir.cpp \ + fs/virtfsdir.h \ + fs/virtfszip.cpp \ + fs/virtfszip.h \ + fs/virtzipentry.cpp \ + fs/virtzipentry.h \ + fs/zip.cpp \ + fs/zip.h \ + fs/ziplocalheader.cpp \ + fs/ziplocalheader.h +endif + if ENABLE_PUGIXML BASE_SRC += utils/xml/pugixml.cpp \ utils/xml/pugixml.h \ @@ -1909,6 +1920,9 @@ TESTS = manaplustests check_PROGRAMS = manaplustests manaplustests_CXXFLAGS = ${manaplus_CXXFLAGS} \ -DUNITTESTS +if USE_PHYSFS +manaplustests_CXXFLAGS += -DUSE_PHYSFS +endif if USE_SDL2 manaplustests_CXXFLAGS += -DUSE_SDL2 endif @@ -1933,12 +1947,20 @@ manaplustests_SOURCES = ${SRC} \ render/mockgraphics.h \ enums/enums_unittest.cc \ utils/dumplibs_unittest.cc \ - utils/checkutils_unittest.cc \ - fs/virtfs_unittest.cc \ - fs/virtfsphys_unittest.cc \ - fs/zip_unittest.cc \ + utils/checkutils_unittest.cc + +if USE_PHYSFS +manaplustests_SOURCES += \ + fs/virtfsphys_unittest.cc +else +manaplustests_SOURCES += \ fs/virtfsdir_unittest.cc \ - fs/virtfszip_unittest.cc \ + fs/zip_unittest.cc \ + fs/virtfszip_unittest.cc +endif + +manaplustests_SOURCES += \ + fs/virtfs_unittest.cc \ utils/xml_unittest.cc \ utils/timer_unittest.cc \ utils/xmlutils_unittest.cc \ diff --git a/src/fs/virtfs.cpp b/src/fs/virtfs.cpp index 7aa30940c..3ba214dc7 100644 --- a/src/fs/virtfs.cpp +++ b/src/fs/virtfs.cpp @@ -20,8 +20,11 @@ #include "fs/virtfs.h" -#include "fs/virtfsdir.h" +#ifdef USE_PHYSFS #include "fs/virtfsphys.h" +#else // USE_PHYSFS +#include "fs/virtfsdir.h" +#endif // USE_PHYSFS #include "fs/virtfile.h" #include "fs/virtfsfuncs.h" #include "fs/virtlist.h" @@ -34,33 +37,52 @@ namespace VirtFs { void init(const std::string &restrict name) { +#ifdef USE_PHYSFS VirtFsPhys::init(name); +#else // USE_PHYSFS VirtFsDir::init(name); +#endif // USE_PHYSFS updateDirSeparator(); } void updateDirSeparator() { +#ifdef USE_PHYSFS + dirSeparator = VirtFsPhys::getDirSeparator(); +#else // USE_PHYSFS #ifdef WIN32 dirSeparator = "\\"; #else // WIN32 dirSeparator = "/"; #endif // WIN32 +#endif // USE_PHYSFS } const char *getDirSeparator() { +#ifdef USE_PHYSFS + return VirtFsPhys::getDirSeparator(); +#else // USE_PHYSFS return dirSeparator; +#endif // USE_PHYSFS } const char *getBaseDir() { +#ifdef USE_PHYSFS + return VirtFsPhys::getBaseDir(); +#else // USE_PHYSFS return VirtFsDir::getBaseDir(); +#endif // USE_PHYSFS } const char *getUserDir() { +#ifdef USE_PHYSFS + return VirtFsPhys::getUserDir(); +#else // USE_PHYSFS return VirtFsDir::getUserDir(); +#endif // USE_PHYSFS } bool exists(const std::string &restrict name) @@ -147,8 +169,12 @@ namespace VirtFs bool deinit() { - VirtFsDir::deinit(); +#ifdef USE_PHYSFS return VirtFsPhys::deinit(); +#else // USE_PHYSFS + VirtFsDir::deinit(); + return true; +#endif // USE_PHYSFS } void permitLinks(const bool val) diff --git a/src/fs/virtfstools.cpp b/src/fs/virtfstools.cpp index c9e976864..39f1ed413 100644 --- a/src/fs/virtfstools.cpp +++ b/src/fs/virtfstools.cpp @@ -224,34 +224,36 @@ namespace VirtFs } } // namespace VirtFs +#ifdef USE_PHYSFS // +++ temporary add it here -namespace VirtFsDir +namespace VirtFsPhys { void getFiles(const std::string &path, StringVect &list) { - VirtList *const fonts = VirtFsDir::enumerateFiles(path); + VirtList *const fonts = VirtFsPhys::enumerateFiles(path); FOR_EACH (StringVectCIter, i, fonts->names) { - if (!VirtFsDir::isDirectory(path + dirSeparator + *i)) + if (!VirtFsPhys::isDirectory(path + dirSeparator + *i)) list.push_back(*i); } - VirtFsDir::freeList(fonts); + VirtFsPhys::freeList(fonts); } } // namespace VirtFs - +#else // USE_PHYSFS // +++ temporary add it here -namespace VirtFsPhys +namespace VirtFsDir { void getFiles(const std::string &path, StringVect &list) { - VirtList *const fonts = VirtFsPhys::enumerateFiles(path); + VirtList *const fonts = VirtFsDir::enumerateFiles(path); FOR_EACH (StringVectCIter, i, fonts->names) { - if (!VirtFsPhys::isDirectory(path + dirSeparator + *i)) + if (!VirtFsDir::isDirectory(path + dirSeparator + *i)) list.push_back(*i); } - VirtFsPhys::freeList(fonts); + VirtFsDir::freeList(fonts); } } // namespace VirtFs +#endif // USE_PHYSFS diff --git a/src/fs/virtfstools.h b/src/fs/virtfstools.h index 3271fee6f..383327404 100644 --- a/src/fs/virtfstools.h +++ b/src/fs/virtfstools.h @@ -51,18 +51,20 @@ namespace VirtFs std::string loadTextFileString(const std::string &fileName); } // namespace VirtFs +#ifdef USE_PHYSFS // +++ temporary add it here -namespace VirtFsDir +namespace VirtFsPhys { void getFiles(const std::string &path, StringVect &list); } // namespace VirtFs - +#else // USE_PHYSFS // +++ temporary add it here -namespace VirtFsPhys +namespace VirtFsDir { void getFiles(const std::string &path, StringVect &list); } // namespace VirtFs +#endif // USE_PHYSFS #endif // UTILS_VIRTFSTOOLS_H |