diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-28 04:10:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-28 04:10:23 +0300 |
commit | 6ff6d6928328ff2110f028a374ade49415d5a0ba (patch) | |
tree | 4337ddc2e83368a2d606b97df08dc206e002ac67 | |
parent | 475aea387f846561d5029807f804ff789d59e69f (diff) | |
download | plus-6ff6d6928328ff2110f028a374ade49415d5a0ba.tar.gz plus-6ff6d6928328ff2110f028a374ade49415d5a0ba.tar.bz2 plus-6ff6d6928328ff2110f028a374ade49415d5a0ba.tar.xz plus-6ff6d6928328ff2110f028a374ade49415d5a0ba.zip |
Remove physfs support.
58 files changed, 12 insertions, 1702 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 717624122..6f6c30476 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -406,35 +406,6 @@ gcc-6_sanitize_i386: tags: - docker -gcc-6_sanitize_physfs: - stage: build - script: - - ./tools/ci/jobs/gcc6_sanitize.sh --with-physfs - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev - tags: - - docker - -gcc-6_sanitize_physfs_i386: - stage: build - script: - - ./tools/ci/jobs/gcc6_sanitize.sh --with-physfs - image: vicamo/debian:sid-i386 - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev - tags: - - docker - .fedora_gcc-snapshot_sanitize_tests: stage: build script: @@ -744,37 +715,6 @@ gcc-6_tests_no_opengl_i386: tags: - docker -gcc-6_tests_physfs: - stage: build - script: - - ./tools/ci/jobs/gcc6_tests.sh --without-dyecmd --without-manaplusgame --with-physfs - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev - valgrind - tags: - - docker - -gcc-6_tests_physfs_i386: - stage: build - script: - - ./tools/ci/jobs/gcc6_tests.sh --without-dyecmd --without-manaplusgame --with-physfs - image: vicamo/debian:sid-i386 - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev - valgrind - tags: - - docker - gcc-6_sdl2_tests_gcov: stage: build script: @@ -805,38 +745,6 @@ gcc-6_sdl2_tests_i386: tags: - docker -gcc-6_sdl2_tests_physfs: - stage: build - script: - - ./tools/ci/jobs/gcc6_sdl2_tests_gcov.sh --without-dyecmd --without-manaplusgame --with-physfs - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev - gcovr - valgrind - tags: - - docker - -gcc-6_sdl2_tests_physfs_i386: - stage: build - script: - - ./tools/ci/jobs/gcc6_sdl2_tests.sh --without-dyecmd --without-manaplusgame --with-physfs - image: vicamo/debian:sid-i386 - <<: *job-shared - variables: - PACKAGES: gcc-6 g++-6 - libphysfs-dev - make autoconf automake autopoint gettext - libxml2-dev libcurl4-gnutls-dev libpng-dev - libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev - valgrind - tags: - - docker - gcc-5_sdl2_tests_glibcdebug: stage: build script: diff --git a/Android.mk b/Android.mk index 81f3ab687..b2c45a0f4 100644 --- a/Android.mk +++ b/Android.mk @@ -83,7 +83,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ $(wildcard $(LOCAL_PATH)/src/test/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/debug/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/fs/*.cpp) \ - $(wildcard $(LOCAL_PATH)/src/fs/physfs/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/fs/virtfs/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/enums/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/enums/being/*.cpp) \ @@ -1,7 +1,7 @@ How to compile and run ManaPlus on your GNU/Linux Box ================================================= -Homepage: http://manaplus.evolonline.org/ +Homepage: http://manaplus.org/ IRC: irc.freenode.net / #manaplus 1) Requirements @@ -23,7 +23,6 @@ and some libraries. The required libraries are: * SDL_ttf http://www.libsdl.org/projects/SDL_ttf/ * SDL_gfx http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx * libxml2 http://www.xmlsoft.org/ -* physfs 1.x http://icculus.org/physfs/ * zlib 1.2.x http://www.gzip.org/zlib/ * libcurl http://curl.haxx.se/libcurl/ diff --git a/PKGBUILD.in b/PKGBUILD.in index 1b94fde0c..2de85a80d 100644 --- a/PKGBUILD.in +++ b/PKGBUILD.in @@ -6,7 +6,7 @@ pkgrel=1 pkgdesc="ManaPlus is a 2D MMORPG game advanced client for games based on eAthena fork The Mana World (tAthena) also for other forks like Evol. More info here: http://manaplus.evolonline.org" arch=('i686' 'x86_64') url="http://manaplus.org" -depends=('libxml2' 'physfs' 'sdl_image' 'sdl_mixer' 'sdl_net' 'sdl_ttf' 'sdl_gfx') +depends=('libxml2' 'sdl_image' 'sdl_mixer' 'sdl_net' 'sdl_ttf' 'sdl_gfx') license=('GPL2') build() { @@ -25,7 +25,6 @@ THE MANA PLUS CLIENT Optional dependencies: - gettext (translations) - - PhysFS (not used by default) Additiona run time deps: - xsel (for clipboard access, used only in SDL 1.2) @@ -35,9 +34,6 @@ THE MANA PLUS CLIENT - data/icons - data/fonts/src - Run time issues: - due PhysFS bug with recent zlib versions, need apply patch to PhysFS from packaging/patches/physfs/zip_seek.diff - 0. Index -------- @@ -33,8 +33,6 @@ Doxygen: [![doxygen](https://img.shields.io/badge/Docs-Doxygen/manaplus-blue.svg - [gettext](https://www.gnu.org/software/gettext/) (translations) - - [PhysFS](https://icculus.org/physfs/) - ### Additional run time deps: - xsel (for clipboard access, used only in SDL 1.2) - xdg-open (from xdg-utils, for open url in browser) @@ -43,9 +41,6 @@ Doxygen: [![doxygen](https://img.shields.io/badge/Docs-Doxygen/manaplus-blue.svg - data/icons - data/fonts/src -### Run time issues: - - due PhysFS bug with recent zlib versions, need apply patch to PhysFS from [packaging/patches/physfs/zip_seek.diff] - ## 0. Index diff --git a/README.txt b/README.txt index a92841ee5..ff39127d4 100644 --- a/README.txt +++ b/README.txt @@ -25,7 +25,6 @@ THE MANA PLUS CLIENT Optional dependencies:
- gettext (translations)
- - PhysFS (not used by default)
Additiona run time deps:
- xsel (for clipboard access, used only in SDL 1.2)
@@ -35,9 +34,6 @@ THE MANA PLUS CLIENT - data/icons
- data/fonts/src
- Run time issues:
- due PhysFS bug with recent zlib versions, need apply patch to PhysFS from packaging/patches/physfs/zip_seek.diff
-
0. Index
--------
diff --git a/build/testfile.sh b/build/testfile.sh index f670bb680..82393caf7 100755 --- a/build/testfile.sh +++ b/build/testfile.sh @@ -21,7 +21,6 @@ function run { -i "\"sdlshared.h\"" \ -i "\"localconsts.h\"" \ -i "\"utils/fuzzer.h\"" \ - -i "\"utils/physfscheckutils.h\"" \ -i "\"$name\"" \ -c "$CXX" \ -d "$1" \ diff --git a/build/testfiledye.sh b/build/testfiledye.sh index ac2ccd777..03dc1dfad 100755 --- a/build/testfiledye.sh +++ b/build/testfiledye.sh @@ -21,7 +21,6 @@ function run { -i "\"sdlshared.h\"" \ -i "\"localconsts.h\"" \ -i "\"utils/fuzzer.h\"" \ - -i "\"utils/physfscheckutils.h\"" \ -i "\"$name\"" \ -c "$CXX" \ -d "$1" \ diff --git a/build/testfiletest.sh b/build/testfiletest.sh index 3708275fd..40f08739a 100755 --- a/build/testfiletest.sh +++ b/build/testfiletest.sh @@ -21,7 +21,6 @@ function run { -i "\"sdlshared.h\"" \ -i "\"localconsts.h\"" \ -i "\"utils/fuzzer.h\"" \ - -i "\"utils/physfscheckutils.h\"" \ -i "\"$name\"" \ -c "$CXX" \ -d "$1" \ diff --git a/configure.ac b/configure.ac index dd51ff4a8..834087ede 100755 --- a/configure.ac +++ b/configure.ac @@ -331,21 +331,6 @@ if test "$skip_check_lib" == "no"; then AC_MSG_ERROR([ *** Unable to find zlib (http://www.gzip.org/zlib/)])) fi -# Option to enable physfs. -AC_ARG_WITH(physfs,[ --with-physfs use physfs (experimental) ] ) -if test "x$with_physfs" == "xyes"; then - with_physfs=yes - if test "$skip_check_lib" == "no"; then - AC_CHECK_LIB([physfs], [PHYSFS_init], , - AC_MSG_ERROR([ *** Unable to find PhysFS library (http://icculus.org/physfs/)])) - fi - AC_CHECK_HEADERS([physfs.h], , - AC_MSG_ERROR([ *** PhysFS library found but cannot find headers (http://icculus.org/physfs/)])) -else - with_physfs=no -fi -AM_CONDITIONAL(USE_PHYSFS, test x$with_physfs = xyes) - if test -n "$CURL_CONFIG"; then LIBS="$LIBS `$CURL_CONFIG --libs`" CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`" @@ -738,7 +723,6 @@ if test "$unittests_enabled" == true; then fi echo "Build with OpenGL: $with_opengl" -echo "Build with physfs: $with_physfs" echo echo "LIBS: $LIBS" echo "CPPFLAGS: $CPPFLAGS" diff --git a/data/help/index.txt b/data/help/index.txt index b920ed68f..bb02caa96 100644 --- a/data/help/index.txt +++ b/data/help/index.txt @@ -17,8 +17,6 @@ <<##2 SDL, SDL_image, SDL_mixer (Media framework) ##2 SDL_net (Networking framework) -##2 Guichan (GUI framework) ##2 libxml2 (XML parsing and writing) -##2 PhysFS (Data files) ##2 libcurl (HTTP downloads) ##2 zlib (Archives)>> diff --git a/docs/clientupdates.txt b/docs/clientupdates.txt index c5e38d8b8..0dd638e33 100644 --- a/docs/clientupdates.txt +++ b/docs/clientupdates.txt @@ -18,7 +18,7 @@ this functionality: from where to get the the missing packages 6. Client downloads them and puts them in "data" directory (~/.mana/data on Linux, cause that's writable) - 7. Client loads the list of files server mentioned in PhysFS virtual + 7. Client loads the list of files server mentioned in VirtFS virtual filesystem 8. Client tells server that it is up to date 9. Client could load some common data like item definitions here diff --git a/manaplus.cbp b/manaplus.cbp index 35741aa58..c7d9833f8 100644 --- a/manaplus.cbp +++ b/manaplus.cbp @@ -707,9 +707,6 @@ <Unit filename="src/fs/virtfstools.cpp" /> <Unit filename="src/fs/mkdir.cpp" /> <Unit filename="src/fs/virtfsrwops.cpp" /> - <Unit filename="src/fs/physfs/virtfsphys.cpp" /> - <Unit filename="src/fs/physfs/virtfs.cpp" /> - <Unit filename="src/fs/physfs/virtfileprivate.cpp" /> <Unit filename="src/fs/virtfs/virtdirentry.cpp" /> <Unit filename="src/fs/virtfs/virtfs.cpp" /> <Unit filename="src/fs/virtfs/virtfszip.cpp" /> @@ -1616,8 +1613,6 @@ <Unit filename="src/vector.h" /> <Unit filename="src/main.h" /> <Unit filename="src/fs/virtfstools.h" /> - <Unit filename="src/fs/physfs/virtfileprivate.h" /> - <Unit filename="src/fs/physfs/virtfsphys.h" /> <Unit filename="src/fs/files.h" /> <Unit filename="src/fs/specialfolder.h" /> <Unit filename="src/fs/virtfsfuncs.h" /> diff --git a/manaplus.spec.in b/manaplus.spec.in index 6e563af68..dee87106a 100644 --- a/manaplus.spec.in +++ b/manaplus.spec.in @@ -16,7 +16,6 @@ BuildRequires: SDL_mixer-devel Buildrequires: SDL_net-devel BuildRequires: SDL_ttf-devel BuildRequires: SDL_gfx-devel -BuildRequires: physfs-devel BuildRequires: libcurl-devel BuildRequires: libxml2-devel BuildRequires: libpng-devel diff --git a/packaging/nacl/ports/manaplus/pkg_info b/packaging/nacl/ports/manaplus/pkg_info index aad0c16bd..314dfb0b7 100644 --- a/packaging/nacl/ports/manaplus/pkg_info +++ b/packaging/nacl/ports/manaplus/pkg_info @@ -2,5 +2,5 @@ NAME=manaplus VERSION=1 #URL=https://gitlab.com/manaplus/manaplus.git@master LICENSE=GPL -DEPENDS=(sdl sdl-gfx sdl-mixer sdl-ttf sdl-image sdl-net physfs curl libxml2 libwebp zlib) +DEPENDS=(sdl sdl-gfx sdl-mixer sdl-ttf sdl-image sdl-net curl libxml2 libwebp zlib) SHA1=4178d0c709b34b811d1781fc6dc183ea4979c2b5 diff --git a/packaging/openSUSE Build Service/manaplus.spec b/packaging/openSUSE Build Service/manaplus.spec index 68475633a..852f6422c 100644 --- a/packaging/openSUSE Build Service/manaplus.spec +++ b/packaging/openSUSE Build Service/manaplus.spec @@ -16,7 +16,6 @@ BuildRequires: SDL_mixer-devel Buildrequires: SDL_net-devel BuildRequires: SDL_ttf-devel BuildRequires: SDL_gfx-devel -BuildRequires: physfs-devel BuildRequires: libcurl-devel BuildRequires: libxml2-devel BuildRequires: libpng-devel diff --git a/src/Makefile.am b/src/Makefile.am index ddf446344..b1b14495b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,11 +90,6 @@ 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 @@ -840,17 +835,7 @@ BASE_SRC += events/actionevent.h \ resources/memorycounter.h \ resources/memorymanager.cpp \ resources/memorymanager.h \ - winver.h - -if USE_PHYSFS -BASE_SRC += \ - fs/physfs/virtfileprivate.cpp \ - fs/physfs/virtfileprivate.h \ - fs/physfs/virtfs.cpp \ - fs/physfs/virtfsphys.cpp \ - fs/physfs/virtfsphys.h -else -BASE_SRC += \ + winver.h \ enums/fs/fsentrytype.h \ fs/virtfs/fileapi.h \ fs/virtfs/virtdirentry.cpp \ @@ -871,7 +856,6 @@ BASE_SRC += \ fs/virtfs/zip.h \ fs/virtfs/ziplocalheader.cpp \ fs/virtfs/ziplocalheader.h -endif if ENABLE_PUGIXML BASE_SRC += utils/xml/pugixml.cpp \ @@ -1962,9 +1946,6 @@ endif if ENABLE_TINYXML2 manaplustests_CXXFLAGS += -DENABLE_TINYXML2 endif -if USE_PHYSFS -manaplustests_CXXFLAGS += -DUSE_PHYSFS -endif if USE_SDL2 manaplustests_CXXFLAGS += -DUSE_SDL2 endif @@ -2001,16 +1982,9 @@ manaplustests_SOURCES += manaplus.rc manaplustests_LDFLAGS += -mconsole endif -if USE_PHYSFS -manaplustests_SOURCES += \ - fs/physfs/virtfsphys_unittest.cc -else manaplustests_SOURCES += \ fs/virtfs/virtfs_unittest.cc \ - fs/virtfs/zip_unittest.cc -endif - -manaplustests_SOURCES += \ + fs/virtfs/zip_unittest.cc \ fs/virtfs_unittest.cc \ utils/xml_unittest.cc \ utils/timer_unittest.cc \ diff --git a/src/debug.h b/src/debug.h index 47ccfc2bb..bd7f200a5 100644 --- a/src/debug.h +++ b/src/debug.h @@ -66,4 +66,4 @@ #ifdef DEBUG_VIRTFS #define RWopsOpenRead(name) RWopsOpenRead(name, __FILE__, __LINE__) -#endif // DEBUG_PHYSFS +#endif // DEBUG_VIRTFS diff --git a/src/dirs.cpp b/src/dirs.cpp index d0352adfd..f1112e639 100644 --- a/src/dirs.cpp +++ b/src/dirs.cpp @@ -234,7 +234,7 @@ void Dirs::mountDataDir() #endif // defined __native_client__ #ifndef WIN32 - // Add branding/data to PhysFS search path + // Add branding/data to VirtFS search path if (!settings.options.brandingPath.empty()) { std::string path = settings.options.brandingPath; diff --git a/src/fs/physfs/virtfileprivate.cpp b/src/fs/physfs/virtfileprivate.cpp deleted file mode 100644 index 6e6cd7dd6..000000000 --- a/src/fs/physfs/virtfileprivate.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_PHYSFS -#include "fs/physfs/virtfileprivate.h" - -#include "debug.h" - -VirtFilePrivate::VirtFilePrivate(PHYSFS_file *restrict const file) : - mFile(file) -{ -} - -VirtFilePrivate::~VirtFilePrivate() -{ - if (mFile != nullptr) - PHYSFS_close(mFile); -} -#endif // USE_PHYSFS diff --git a/src/fs/physfs/virtfileprivate.h b/src/fs/physfs/virtfileprivate.h deleted file mode 100644 index 1067cfda0..000000000 --- a/src/fs/physfs/virtfileprivate.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef UTILS_VIRTFILEPRIVATE_H -#define UTILS_VIRTFILEPRIVATE_H -#ifdef USE_PHYSFS - -#include "localconsts.h" - -PRAGMA45(GCC diagnostic push) -PRAGMA45(GCC diagnostic ignored "-Wlong-long") -#include <physfs.h> -PRAGMA45(GCC diagnostic pop) - -struct VirtFilePrivate final -{ - explicit VirtFilePrivate(PHYSFS_file *restrict const file); - - A_DELETE_COPY(VirtFilePrivate) - - ~VirtFilePrivate(); - - // physfs fields - PHYSFS_file *mFile; -}; - -#endif // USE_PHYSFS -#endif // UTILS_VIRTFILEPRIVATE_H diff --git a/src/fs/physfs/virtfs.cpp b/src/fs/physfs/virtfs.cpp deleted file mode 100644 index c9fd34ba4..000000000 --- a/src/fs/physfs/virtfs.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_PHYSFS - -#include "fs/virtfs.h" - -#include "fs/physfs/virtfsphys.h" -#include "fs/virtfile.h" -#include "fs/virtfsfuncs.h" -#include "fs/virtlist.h" - -#include "debug.h" - -const char *dirSeparator = nullptr; - -namespace VirtFs -{ - void init(const std::string &restrict name) - { - VirtFsPhys::init(name); - updateDirSeparator(); - } - - void updateDirSeparator() - { - dirSeparator = VirtFsPhys::getDirSeparator(); - } - - const char *getDirSeparator() - { - return dirSeparator; - } - - const char *getBaseDir() - { - return VirtFsPhys::getBaseDir(); - } - - const char *getUserDir() - { - return VirtFsPhys::getUserDir(); - } - - bool exists(std::string name) - { - return VirtFsPhys::exists(name); - } - - VirtList *enumerateFiles(std::string dirName) - { - return VirtFsPhys::enumerateFiles(dirName); - } - - bool isDirectory(std::string name) - { - return VirtFsPhys::isDirectory(name); - } - - bool isSymbolicLink(const std::string &restrict name) - { - return VirtFsPhys::isSymbolicLink(name); - } - - void freeList(VirtList *restrict const handle) - { - delete handle; - } - - VirtFile *openRead(std::string filename) - { - return VirtFsPhys::openRead(filename); - } - - VirtFile *openWrite(std::string filename) - { - return VirtFsPhys::openWrite(filename); - } - - VirtFile *openAppend(std::string filename) - { - return VirtFsPhys::openAppend(filename); - } - - bool setWriteDir(const std::string &restrict newDir) - { - return VirtFsPhys::setWriteDir(newDir); - } - - bool mountDir(std::string newDir, - const Append append) - { - return VirtFsPhys::mountDir(newDir, append); - } - - bool mountDirSilent(std::string newDir, - const Append append) - { - return VirtFsPhys::mountDir(newDir, append); - } - - bool unmountDir(std::string oldDir) - { - return VirtFsPhys::unmountDir(oldDir); - } - - bool unmountDirSilent(std::string oldDir) - { - return VirtFsPhys::unmountDir(oldDir); - } - - bool mountZip(std::string newDir, - const Append append) - { - return VirtFsPhys::mountZip(newDir, append); - } - - bool unmountZip(std::string oldDir) - { - return VirtFsPhys::unmountZip(oldDir); - } - - std::string getRealDir(std::string filename) - { - return VirtFsPhys::getRealDir(filename); - } - - bool mkdir(const std::string &restrict dirname) - { - return VirtFsPhys::mkdir(dirname); - } - - bool remove(const std::string &restrict filename) - { - return VirtFsPhys::remove(filename); - } - - bool deinit() - { - return VirtFsPhys::deinit(); - } - - void permitLinks(const bool val) - { - VirtFsPhys::permitLinks(val); - } - - const char *getLastError() - { - return VirtFsPhys::getLastError(); - } - - int close(VirtFile *restrict const file) - { - if (file == nullptr) - return 0; - return file->funcs->close(file); - } - - int64_t read(VirtFile *restrict const file, - void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount) - { - return file->funcs->read(file, - buffer, - objSize, - objCount); - } - - int64_t write(VirtFile *restrict const file, - const void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount) - { - return file->funcs->write(file, - buffer, - objSize, - objCount); - } - - int64_t fileLength(VirtFile *restrict const file) - { - return file->funcs->fileLength(file); - } - - int64_t tell(VirtFile *restrict const file) - { - return file->funcs->tell(file); - } - - int seek(VirtFile *restrict const file, - const uint64_t pos) - { - return file->funcs->seek(file, - pos); - } - - int eof(VirtFile *restrict const file) - { - return file->funcs->eof(file); - } -} // namespace VirtFs -#endif // USE_PHYSFS diff --git a/src/fs/physfs/virtfsphys.cpp b/src/fs/physfs/virtfsphys.cpp deleted file mode 100644 index f6d0abf47..000000000 --- a/src/fs/physfs/virtfsphys.cpp +++ /dev/null @@ -1,354 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_PHYSFS - -#include "fs/physfs/virtfsphys.h" - -#include "fs/virtfile.h" -#include "fs/virtfsfuncs.h" -#include "fs/virtlist.h" - -#include "fs/physfs/virtfileprivate.h" - -#include "utils/checkutils.h" - -#include <iostream> -#include <unistd.h> - -#ifdef ANDROID -#include "fs/paths.h" -#endif // ANDROID - -#include "debug.h" - -namespace -{ - const char *dirSeparator = nullptr; - VirtFsFuncs funcs; -} // namespace - -namespace VirtFsPhys -{ -#if defined(__native_client__) - void init(const std::string &restrict name A_UNUSED) - { - if (!PHYSFS_init("/fakebinary")) -#elif defined(ANDROID) - void init(const std::string &restrict name A_UNUSED) - { - if (!PHYSFS_init((getRealPath(".").append("/fakebinary")).c_str())) -#else // defined(__native_client__) - - void init(const std::string &restrict name) - { - if (!PHYSFS_init(name.c_str())) -#endif // defined(__native_client__) - { - std::cout << "Error while initializing PhysFS: " - << VirtFsPhys::getLastError() << std::endl; - _exit(1); - } - updateDirSeparator(); - atexit(reinterpret_cast<void(*)()>(PHYSFS_deinit)); - initFuncs(&funcs); - } - - void initFuncs() - { - initFuncs(&funcs); - } - - void initFuncs(VirtFsFuncs *restrict const ptr) - { - ptr->close = &VirtFsPhys::close; - ptr->read = &VirtFsPhys::read; - ptr->write = &VirtFsPhys::write; - ptr->fileLength = &VirtFsPhys::fileLength; - ptr->tell = &VirtFsPhys::tell; - ptr->seek = &VirtFsPhys::seek; - ptr->eof = &VirtFsPhys::eof; - } - - void updateDirSeparator() - { - dirSeparator = PHYSFS_getDirSeparator(); - } - - const char *getDirSeparator() - { - return dirSeparator; - } - - const char *getBaseDir() - { - return PHYSFS_getBaseDir(); - } - - const char *getUserDir() - { - return PHYSFS_getUserDir(); - } - - bool exists(const std::string &restrict name) - { - return PHYSFS_exists(name.c_str()); - } - - VirtList *enumerateFiles(const std::string &restrict dir) - { - char ** handle = PHYSFS_enumerateFiles(dir.c_str()); - VirtList *const files = new VirtList; - if (handle == nullptr) - return files; - for (const char *const *i = handle; *i; i++) - { - std::string str = *i; - files->names.push_back(str); - } - PHYSFS_freeList(handle); - return files; - } - - bool isDirectory(const std::string &restrict name) - { - return PHYSFS_isDirectory(name.c_str()); - } - - bool isSymbolicLink(const std::string &restrict name) - { - return PHYSFS_isSymbolicLink(name.c_str()); - } - - void freeList(VirtList *restrict const handle) - { - delete handle; - } - - VirtFile *openRead(const std::string &restrict filename) - { - PHYSFS_file *restrict const handle = PHYSFS_openRead( - filename.c_str()); - if (!handle) - return nullptr; - VirtFile *restrict const file = new VirtFile(&funcs); - file->mPrivate = new VirtFilePrivate(handle); - return file; - } - - VirtFile *openWrite(const std::string &restrict filename) - { - PHYSFS_file *restrict const handle = PHYSFS_openWrite( - filename.c_str()); - if (!handle) - return nullptr; - VirtFile *restrict const file = new VirtFile(&funcs); - file->mPrivate = new VirtFilePrivate(handle); - return file; - } - - VirtFile *openAppend(const std::string &restrict filename) - { - PHYSFS_file *restrict const handle = PHYSFS_openAppend( - filename.c_str()); - if (!handle) - return nullptr; - VirtFile *restrict const file = new VirtFile(&funcs); - file->mPrivate = new VirtFilePrivate(handle); - return file; - } - - bool setWriteDir(const std::string &restrict newDir) - { - return PHYSFS_setWriteDir(newDir.c_str()); - } - - bool mountDir(const std::string &restrict newDir, - const Append append) - { - logger->log("Add virtual directory: " + newDir); - if (newDir.find(".zip") != std::string::npos) - { - reportAlways("Called mountDir with zip archive"); - return false; - } - const int ret = PHYSFS_addToSearchPath(newDir.c_str(), - append == Append_true ? 1 : 0); - if (ret == 0) - { - logger->log("mountDir error: %s", - VirtFsPhys::getLastError()); - } - return ret; - } - - bool unmountDir(const std::string &restrict oldDir) - { - logger->log("Remove virtual directory: " + oldDir); - if (oldDir.find(".zip") != std::string::npos) - { - reportAlways("Called unmountDir with zip archive"); - return false; - } - const int ret = PHYSFS_removeFromSearchPath(oldDir.c_str()); - if (ret == 0) - { - logger->log("unmountDir error: %s", - VirtFsPhys::getLastError()); - } - return ret; - } - - bool mountZip(const std::string &restrict newDir, - const Append append) - { - logger->log("Add virtual zip: " + newDir); - if (newDir.find(".zip") == std::string::npos) - { - reportAlways("Called mountZip without zip archive"); - return false; - } - const int ret = PHYSFS_addToSearchPath(newDir.c_str(), - append == Append_true ? 1 : 0); - if (ret == 0) - { - logger->log("mountZip error: %s", - VirtFsPhys::getLastError()); - } - return ret; - } - - bool unmountZip(const std::string &restrict oldDir) - { - logger->log("Remove virtual zip: " + oldDir); - if (oldDir.find(".zip") == std::string::npos) - { - reportAlways("Called unmountZip without zip archive"); - return false; - } - const int ret = PHYSFS_removeFromSearchPath(oldDir.c_str()); - if (ret == 0) - { - logger->log("unmountZip error: %s", - VirtFsPhys::getLastError()); - } - return ret; - } - - std::string getRealDir(const std::string &restrict filename) - { - const char *const str = PHYSFS_getRealDir(filename.c_str()); - if (str == nullptr) - return std::string(); - return str; - } - - bool mkdir(const std::string &restrict dirname) - { - return PHYSFS_mkdir(dirname.c_str()); - } - - bool remove(const std::string &restrict filename) - { - return PHYSFS_delete(filename.c_str()); - } - - bool deinit() - { - if (PHYSFS_deinit() != 0) - { - logger->log("Physfs deinit error: %s", - VirtFsPhys::getLastError()); - return false; - } - return true; - } - - void permitLinks(const bool val) - { - PHYSFS_permitSymbolicLinks(val ? 1 : 0); - } - - const char *getLastError() - { - return PHYSFS_getLastError(); - } - - int close(VirtFile *restrict const file) - { - if (file == nullptr) - return 0; - delete file; - return 1; - } - - int64_t read(VirtFile *restrict const file, - void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount) - { - if (file == nullptr) - return 0; - return PHYSFS_read(file->mPrivate->mFile, - buffer, - objSize, - objCount); - } - - int64_t write(VirtFile *restrict const file, - const void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount) - { - if (file == nullptr) - return 0; - return PHYSFS_write(file->mPrivate->mFile, - buffer, - objSize, - objCount); - } - - int64_t fileLength(VirtFile *restrict const file) - { - if (file == nullptr) - return -1; - return PHYSFS_fileLength(file->mPrivate->mFile); - } - - int64_t tell(VirtFile *restrict const file) - { - if (file == nullptr) - return -1; - return PHYSFS_tell(file->mPrivate->mFile); - } - - int seek(VirtFile *restrict const file, - const uint64_t pos) - { - return PHYSFS_seek(file->mPrivate->mFile, - pos); - } - - int eof(VirtFile *restrict const file) - { - return PHYSFS_eof(file->mPrivate->mFile); - } -} // namespace VirtFsPhys -#endif // USE_PHYSFS diff --git a/src/fs/physfs/virtfsphys.h b/src/fs/physfs/virtfsphys.h deleted file mode 100644 index 1daebfb4f..000000000 --- a/src/fs/physfs/virtfsphys.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef UTILS_VIRTFSPHYS_H -#define UTILS_VIRTFSPHYS_H - -#ifdef USE_PHYSFS - -#include "enums/simpletypes/append.h" - -#include "localconsts.h" - -#include <string> - -struct VirtFile; -struct VirtFsFuncs; -struct VirtList; - -namespace VirtFsPhys -{ - void init(const std::string &restrict name); - void initFuncs(VirtFsFuncs *restrict const ptr); - void initFuncs(); - void updateDirSeparator(); - const char *getDirSeparator(); - const char *getBaseDir(); - const char *getUserDir(); - bool exists(const std::string &restrict name); - VirtList *enumerateFiles(const std::string &restrict dir) RETURNS_NONNULL; - bool isDirectory(const std::string &restrict name); - bool isSymbolicLink(const std::string &restrict name); - void freeList(VirtList *restrict const handle); - VirtFile *openRead(const std::string &restrict filename); - VirtFile *openWrite(const std::string &restrict filename); - VirtFile *openAppend(const std::string &restrict filename); - bool setWriteDir(const std::string &restrict newDir); - bool mountDir(const std::string &restrict newDir, - const Append append); - bool unmountDir(const std::string &restrict oldDir); - bool mountZip(const std::string &restrict newDir, - const Append append); - bool unmountZip(const std::string &restrict oldDir); - std::string getRealDir(const std::string &restrict filename); - bool mkdir(const std::string &restrict dirName); - bool remove(const std::string &restrict filename); - bool deinit(); - void permitLinks(const bool val); - const char *getLastError(); - int64_t read(VirtFile *restrict const handle, - void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount); - int64_t write(VirtFile *restrict const file, - const void *restrict const buffer, - const uint32_t objSize, - const uint32_t objCount); - int close(VirtFile *restrict const file); - int64_t fileLength(VirtFile *restrict const file); - int64_t tell(VirtFile *restrict const file); - int seek(VirtFile *restrict const file, - const uint64_t pos); - int eof(VirtFile *restrict const file); -} // namespace VirtFsPhys - -#endif // USE_PHYSFS -#endif // UTILS_VIRTFSPHYS_H diff --git a/src/fs/physfs/virtfsphys_unittest.cc b/src/fs/physfs/virtfsphys_unittest.cc deleted file mode 100644 index 636d67a91..000000000 --- a/src/fs/physfs/virtfsphys_unittest.cc +++ /dev/null @@ -1,505 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2016-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef USE_PHYSFS -#include "catch.hpp" - -#include "fs/paths.h" -#include "fs/virtfs.h" -#include "fs/virtlist.h" - -#include "fs/physfs/virtfsphys.h" - -#include "utils/checkutils.h" -#include "utils/delete2.h" - -#include "debug.h" - -TEST_CASE("VirtFsPhys dirSeparator") -{ - VirtFsPhys::initFuncs(); - REQUIRE(VirtFs::getDirSeparator() != nullptr); - REQUIRE(VirtFsPhys::getDirSeparator() == - std::string(VirtFs::getDirSeparator())); - VirtFsPhys::updateDirSeparator(); - REQUIRE(VirtFs::getDirSeparator() != nullptr); - REQUIRE(VirtFsPhys::getDirSeparator() == - std::string(VirtFs::getDirSeparator())); -} - -TEST_CASE("VirtFsPhys getBaseDir") -{ - VirtFsPhys::initFuncs(); - REQUIRE(VirtFsPhys::getBaseDir() != nullptr); -} - -TEST_CASE("VirtFsPhys getUserDir") -{ - VirtFsPhys::initFuncs(); - REQUIRE(VirtFsPhys::getUserDir() != nullptr); - REQUIRE(VirtFsPhys::getUserDir() == getHomePath()); -} - -TEST_CASE("VirtFsPhys exists") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - VirtFsPhys::mountDir("data", Append_false); - VirtFsPhys::mountDir("../data", Append_false); - - REQUIRE(VirtFsPhys::exists("test/units.xml") == true); - REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); - REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::exists("units.xml") == false); - - VirtFsPhys::mountDir("data/test", Append_false); - VirtFsPhys::mountDir("../data/test", Append_false); - - REQUIRE(VirtFsPhys::exists("test/units.xml") == true); - REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); - REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::exists("units.xml") == true); - - VirtFsPhys::unmountDir("data/test"); - VirtFsPhys::unmountDir("../data/test"); - - REQUIRE(VirtFsPhys::exists("test/units.xml") == true); - REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); - REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::exists("units.xml") == false); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys exists2") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - VirtFsPhys::mountZip("data/test/test2.zip", Append_false); - VirtFsPhys::mountZip("../data/test/test2.zip", Append_false); - - REQUIRE(VirtFsPhys::exists("test/units.xml") == false); - REQUIRE(VirtFsPhys::exists("test.txt") == true); - REQUIRE(VirtFsPhys::exists("units123.xml") == false); - REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::exists("units.xml") == true); - - VirtFsPhys::unmountZip("data/test/test2.zip"); - VirtFsPhys::unmountZip("../data/test/test2.zip"); - delete2(logger); -} - -static void removeTemp(StringVect &restrict list) -{ - int cnt = 0; - std::sort(list.begin(), list.end()); - - FOR_EACH (StringVectIter, it, list) - { - if (*it != "serverlistplus.xml.part") - { - logger->log("file: %d %s", - cnt, - (*it).c_str()); - cnt ++; - } - } - - FOR_EACH (StringVectIter, it, list) - { - if (*it == "serverlistplus.xml.part") - { - list.erase(it); - return; - } - } -} - -TEST_CASE("VirtFsPhys enumerateFiles1") -{ - VirtFsPhys::initFuncs(); - logger = new Logger; - - VirtFsPhys::mountDir("data", Append_false); - VirtFsPhys::mountDir("../data", Append_false); - - VirtList *list = nullptr; - - const int cnt1 = VirtFsPhys::exists("test/test2.txt") ? 28 : 27; - const int cnt2 = 28; - - VirtFsPhys::permitLinks(false); - list = VirtFsPhys::enumerateFiles("test"); - removeTemp(list->names); - const size_t sz = list->names.size(); - REQUIRE(sz == cnt1); - VirtFsPhys::freeList(list); - - VirtFsPhys::permitLinks(true); - list = VirtFsPhys::enumerateFiles("test"); - removeTemp(list->names); - REQUIRE(list->names.size() == cnt2); - VirtFsPhys::freeList(list); - - VirtFsPhys::permitLinks(false); - list = VirtFsPhys::enumerateFiles("test"); - removeTemp(list->names); - REQUIRE(list->names.size() == cnt1); - VirtFsPhys::freeList(list); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys enumerateFiles2") -{ - VirtFsPhys::initFuncs(); - logger = new Logger; - - VirtFsPhys::mountDir("data/test/dir1", - Append_false); - VirtFsPhys::mountDir("../data/test/dir1", - Append_false); - - VirtList *list = nullptr; - - list = VirtFsPhys::enumerateFiles("/"); - REQUIRE(list->names.size() == 5); - VirtFsPhys::freeList(list); - - VirtFsPhys::unmountDir("data/test/dir1"); - VirtFsPhys::unmountDir("../data/test/dir1"); - delete2(logger); -} - -static bool inList(VirtList *list, - const std::string &name) -{ - FOR_EACH (StringVectCIter, it, list->names) - { - if (*it == name) - return true; - } - return false; -} - -TEST_CASE("VirtFsPhys enumerateFiles3") -{ - VirtFsPhys::initFuncs(); - logger = new Logger; - - VirtFsPhys::mountZip("data/test/test.zip", - Append_false); - VirtFsPhys::mountZip("../data/test/test.zip", - Append_false); - - VirtList *list = nullptr; - - list = VirtFsPhys::enumerateFiles("/"); - REQUIRE(inList(list, "units.xml") == false); - REQUIRE(inList(list, "test.txt") == false); - VirtFsPhys::freeList(list); - - VirtFsPhys::unmountZip("data/test/test.zip"); - VirtFsPhys::unmountZip("../data/test/test.zip"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys enumerateFiles4") -{ - VirtFsPhys::initFuncs(); - logger = new Logger; - - VirtFsPhys::mountZip("data/test/test2.zip", - Append_false); - VirtFsPhys::mountZip("../data/test/test2.zip", - Append_false); - - VirtList *list = nullptr; - - list = VirtFsPhys::enumerateFiles("/"); - REQUIRE(inList(list, "units.xml") == true); - REQUIRE(inList(list, "test.txt") == true); - VirtFsPhys::freeList(list); - - VirtFsPhys::unmountZip("data/test/test2.zip"); - VirtFsPhys::unmountZip("../data/test/test2.zip"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys isDirectory") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - VirtFsPhys::mountDir("data", Append_false); - VirtFsPhys::mountDir("../data", Append_false); - - REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test/units.xml/") == false); - REQUIRE(VirtFsPhys::isDirectory("test//units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test/units123.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test//units123.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("tesQ//units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test") == true); - REQUIRE(VirtFsPhys::isDirectory("test/") == true); - REQUIRE(VirtFsPhys::isDirectory("test//") == true); - REQUIRE(VirtFsPhys::isDirectory("test/dir1") == true); - REQUIRE(VirtFsPhys::isDirectory("test//dir1") == true); - REQUIRE(VirtFsPhys::isDirectory("test//dir1/") == true); - REQUIRE(VirtFsPhys::isDirectory("test//dir1//") == true); - REQUIRE(VirtFsPhys::isDirectory("test/dir1/") == true); - REQUIRE(VirtFsPhys::isDirectory("test/dir1//") == true); - REQUIRE(VirtFsPhys::isDirectory("testQ") == false); - REQUIRE(VirtFsPhys::isDirectory("testQ/") == false); - REQUIRE(VirtFsPhys::isDirectory("testQ//") == false); - - VirtFsPhys::mountDir("data/test", Append_false); - VirtFsPhys::mountDir("../data/test", Append_false); - - REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test/units.xml/") == false); - REQUIRE(VirtFsPhys::isDirectory("test//units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test/units123.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test") == true); - REQUIRE(VirtFsPhys::isDirectory("testQ") == false); - REQUIRE(VirtFsPhys::isDirectory("test/dir1") == true); - - VirtFsPhys::unmountDir("data/test"); - VirtFsPhys::unmountDir("../data/test"); - - REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("test/units123.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("tesQ/units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("units.xml") == false); - REQUIRE(VirtFsPhys::isDirectory("units.xml/") == false); - REQUIRE(VirtFsPhys::isDirectory("test") == true); - REQUIRE(VirtFsPhys::isDirectory("test/") == true); - REQUIRE(VirtFsPhys::isDirectory("testQ") == false); - REQUIRE(VirtFsPhys::isDirectory("test/dir1") == true); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys openRead") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - VirtFsPhys::mountDir("data", Append_false); - VirtFsPhys::mountDir("../data", Append_false); - - VirtFile *file = nullptr; - - file = VirtFsPhys::openRead("test/units.xml"); - REQUIRE(file != nullptr); - VirtFsPhys::close(file); - file = VirtFsPhys::openRead("test/units123.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("tesQ/units.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("units.xml"); - REQUIRE(file == nullptr); -// file = VirtFsPhys::openRead("test"); -// REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("testQ"); - REQUIRE(file == nullptr); - - VirtFsPhys::mountDir("data/test", Append_false); - VirtFsPhys::mountDir("../data/test", Append_false); - - file = VirtFsPhys::openRead("test/units.xml"); - REQUIRE(file != nullptr); - VirtFsPhys::close(file); - file = VirtFsPhys::openRead("test/units123.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("tesQ/units.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("units.xml"); - REQUIRE(file != nullptr); - VirtFsPhys::close(file); -// file = VirtFsPhys::openRead("test"); -// REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("testQ"); - REQUIRE(file == nullptr); - - VirtFsPhys::unmountDir("data/test"); - VirtFsPhys::unmountDir("../data/test"); - - file = VirtFsPhys::openRead("test/units.xml"); - REQUIRE(file != nullptr); - VirtFsPhys::close(file); - file = VirtFsPhys::openRead("test/units123.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("tesQ/units.xml"); - REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("units.xml"); - REQUIRE(file == nullptr); -// file = VirtFsPhys::openRead("test"); -// REQUIRE(file == nullptr); - file = VirtFsPhys::openRead("testQ"); - REQUIRE(file == nullptr); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys mountZip") -{ - // +++ need implement -} - -TEST_CASE("VirtFsPhys unmountZip") -{ - // +++ need implement -} - -TEST_CASE("VirtFsPhys getRealDir") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - REQUIRE(VirtFsPhys::getRealDir(".") == ""); - REQUIRE(VirtFsPhys::getRealDir("..") == ""); - const bool dir1 = VirtFsPhys::mountDir("data", Append_false); - REQUIRE((dir1 || VirtFsPhys::mountDir( - "../data", Append_false)) == true); - if (dir1 == true) - { - REQUIRE(VirtFsPhys::getRealDir("test") == "data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "data"); - } - else - { - REQUIRE(VirtFsPhys::getRealDir("test") == "../data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "../data"); - } - REQUIRE(VirtFsPhys::getRealDir("zzz") == ""); - - VirtFsPhys::mountDir("data/test", Append_false); - VirtFsPhys::mountDir("../data/test", Append_false); - if (dir1 == true) - { - REQUIRE(VirtFsPhys::getRealDir("test") == "data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "data"); - REQUIRE(VirtFsPhys::getRealDir("test.txt") == - "data/test"); - } - else - { - REQUIRE(VirtFsPhys::getRealDir("test") == "../data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "../data"); - REQUIRE(VirtFsPhys::getRealDir("test.txt") == - "../data/test"); - } - REQUIRE(VirtFsPhys::getRealDir("zzz") == ""); - - if (dir1 == true) - { - VirtFsPhys::mountZip("data/test/test.zip", Append_false); - REQUIRE(VirtFsPhys::getRealDir("dir/brimmedhat.png") == - "data/test/test.zip"); - REQUIRE(VirtFsPhys::getRealDir("hide.png") == "data/test"); - } - else - { - VirtFsPhys::mountZip("../data/test/test.zip", Append_false); - REQUIRE(VirtFsPhys::getRealDir("dir/brimmedhat.png") == - "../data/test/test.zip"); - REQUIRE(VirtFsPhys::getRealDir("hide.png") == "../data/test"); - } - - VirtFsPhys::unmountDir("data/test"); - VirtFsPhys::unmountDir("../data/test"); - - if (dir1 == true) - { - REQUIRE(VirtFsPhys::getRealDir("test") == "data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "data"); - REQUIRE(VirtFsPhys::getRealDir("dir/hide.png") == - "data/test/test.zip"); - } - else - { - REQUIRE(VirtFsPhys::getRealDir("test") == "../data"); - REQUIRE(VirtFsPhys::getRealDir("test/test.txt") == - "../data"); - REQUIRE(VirtFsPhys::getRealDir("dir/hide.png") == - "../data/test/test.zip"); - } - REQUIRE(VirtFsPhys::exists("dir/hide.png")); - REQUIRE(VirtFsPhys::getRealDir("zzz") == ""); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - VirtFsPhys::unmountZip("data/test/test.zip"); - VirtFsPhys::unmountZip("../data/test/test.zip"); - delete2(logger); -} - -TEST_CASE("VirtFsPhys read") -{ - VirtFsPhys::initFuncs(); - logger = new Logger(); - VirtFsPhys::mountDir("data", Append_false); - VirtFsPhys::mountDir("../data", Append_false); - - VirtFile *file = VirtFsPhys::openRead("test/test.txt"); - REQUIRE(file != nullptr); - REQUIRE(VirtFsPhys::fileLength(file) == 23); - const int fileSize = VirtFsPhys::fileLength(file); - - void *restrict buffer = calloc(fileSize + 1, 1); - REQUIRE(VirtFsPhys::read(file, buffer, 1, fileSize) == fileSize); - REQUIRE(strcmp(static_cast<char*>(buffer), - "test line 1\ntest line 2") == 0); - REQUIRE(VirtFsPhys::tell(file) == fileSize); - REQUIRE(VirtFsPhys::eof(file) == true); - - free(buffer); - buffer = calloc(fileSize + 1, 1); - REQUIRE(VirtFsPhys::seek(file, 12) != 0); - REQUIRE(VirtFsPhys::eof(file) == false); - REQUIRE(VirtFsPhys::tell(file) == 12); - REQUIRE(VirtFsPhys::read(file, buffer, 1, 11) == 11); - REQUIRE(strcmp(static_cast<char*>(buffer), - "test line 2") == 0); - REQUIRE(VirtFsPhys::eof(file) == true); - - VirtFsPhys::close(file); - free(buffer); - - VirtFsPhys::unmountDir("data"); - VirtFsPhys::unmountDir("../data"); - delete2(logger); -} -#endif // USE_PHYSFS diff --git a/src/fs/virtfile.cpp b/src/fs/virtfile.cpp index 766c193d5..ff7be9627 100644 --- a/src/fs/virtfile.cpp +++ b/src/fs/virtfile.cpp @@ -20,11 +20,7 @@ #include "fs/virtfile.h" -#ifdef USE_PHYSFS -#include "fs/physfs/virtfileprivate.h" -#else // USE_PHYSFS #include "fs/virtfs/virtfileprivate.h" -#endif // USE_PHYSFS #include "debug.h" diff --git a/src/fs/virtfs/fileapi.h b/src/fs/virtfs/fileapi.h index 121506816..14e7b8204 100644 --- a/src/fs/virtfs/fileapi.h +++ b/src/fs/virtfs/fileapi.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTFS_FILEAPI_H #define UTILS_VIRTFS_FILEAPI_H -#ifndef USE_PHYSFS #include "localconsts.h" @@ -46,5 +45,4 @@ #define FILEOPEN_FLAG_APPEND O_WRONLY | O_CREAT | O_APPEND #endif // USE_FILE_FOPEN -#endif // USE_PHYSFS #endif // UTILS_VIRTFS_FILEAPI_H diff --git a/src/fs/virtfs/virtdirentry.cpp b/src/fs/virtfs/virtdirentry.cpp index 3cf8dd600..a24fb12f5 100644 --- a/src/fs/virtfs/virtdirentry.cpp +++ b/src/fs/virtfs/virtdirentry.cpp @@ -18,7 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS #include "fs/virtfs/virtdirentry.h" #include "debug.h" @@ -35,4 +34,3 @@ VirtDirEntry::VirtDirEntry(const std::string &userDir0, VirtDirEntry::~VirtDirEntry() { } -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtdirentry.h b/src/fs/virtfs/virtdirentry.h index a1cc4a24f..282eb21cd 100644 --- a/src/fs/virtfs/virtdirentry.h +++ b/src/fs/virtfs/virtdirentry.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTDIRENTRY_H #define UTILS_VIRTDIRENTRY_H -#ifndef USE_PHYSFS #include "fs/virtfs/virtfsentry.h" @@ -39,5 +38,4 @@ struct VirtDirEntry final : public VirtFsEntry std::string userDir; }; -#endif // USE_PHYSFS #endif // UTILS_VIRTDIRENTRY_H diff --git a/src/fs/virtfs/virtfileprivate.cpp b/src/fs/virtfs/virtfileprivate.cpp index eac55571e..57f06e986 100644 --- a/src/fs/virtfs/virtfileprivate.cpp +++ b/src/fs/virtfs/virtfileprivate.cpp @@ -18,7 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS #include "fs/virtfs/virtfileprivate.h" #include "debug.h" @@ -54,4 +53,3 @@ VirtFilePrivate::~VirtFilePrivate() FILECLOSE(mFd); delete [] mBuf; } -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfileprivate.h b/src/fs/virtfs/virtfileprivate.h index a9e1edf3e..d96cb5781 100644 --- a/src/fs/virtfs/virtfileprivate.h +++ b/src/fs/virtfs/virtfileprivate.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTFILEPRIVATE_H #define UTILS_VIRTFILEPRIVATE_H -#ifndef USE_PHYSFS #include "localconsts.h" @@ -50,5 +49,4 @@ struct VirtFilePrivate final FILEHTYPE mFd; }; -#endif // USE_PHYSFS #endif // UTILS_VIRTFILEPRIVATE_H diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp index dd305303a..fbcb5b2ef 100644 --- a/src/fs/virtfs/virtfs.cpp +++ b/src/fs/virtfs/virtfs.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs.h" #include "fs/files.h" @@ -570,4 +568,3 @@ namespace VirtFs return file->funcs->eof(file); } } // namespace VirtFs -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc index 126c3e1a7..1d5087e05 100644 --- a/src/fs/virtfs/virtfs_unittest.cc +++ b/src/fs/virtfs/virtfs_unittest.cc @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "catch.hpp" #include "fs/files.h" @@ -1422,5 +1420,3 @@ TEST_CASE("VirtFs1 read2") VirtFs::deinit(); delete2(logger); } - -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp index 2092fcf31..357702de6 100644 --- a/src/fs/virtfs/virtfsdir.cpp +++ b/src/fs/virtfs/virtfsdir.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/virtfsdir.h" #include "fs/files.h" @@ -447,4 +445,3 @@ namespace VirtFsDir return pos < 0 || len < 0 || pos >= len; } } // namespace VirtFs -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfsdir.h b/src/fs/virtfs/virtfsdir.h index b292bd71d..f85100e84 100644 --- a/src/fs/virtfs/virtfsdir.h +++ b/src/fs/virtfs/virtfsdir.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTFSDIR_H #define UTILS_VIRTFSDIR_H -#ifndef USE_PHYSFS #include "fs/virtfs/fileapi.h" @@ -85,5 +84,4 @@ namespace VirtFsDir int eof(VirtFile *restrict const file); } // namespace VirtFsDir -#endif // USE_PHYSFS #endif // UTILS_VIRTFSDIR_H diff --git a/src/fs/virtfs/virtfsentry.cpp b/src/fs/virtfs/virtfsentry.cpp index efffd0927..09f68148a 100644 --- a/src/fs/virtfs/virtfsentry.cpp +++ b/src/fs/virtfs/virtfsentry.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/virtfsentry.h" #include "debug.h" @@ -35,5 +33,3 @@ VirtFsEntry::VirtFsEntry(const FsEntryTypeT &type0, VirtFsEntry::~VirtFsEntry() { } - -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfsentry.h b/src/fs/virtfs/virtfsentry.h index 56a1e71ee..467d374cb 100644 --- a/src/fs/virtfs/virtfsentry.h +++ b/src/fs/virtfs/virtfsentry.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTFSENTRY_H #define UTILS_VIRTFSENTRY_H -#ifndef USE_PHYSFS #include "enums/fs/fsentrytype.h" @@ -46,5 +45,4 @@ struct VirtFsEntry notfinal VirtFsFuncs *funcs; }; -#endif // USE_PHYSFS #endif // UTILS_VIRTFSENTRY_H diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp index e085ac307..e9414136f 100644 --- a/src/fs/virtfs/virtfszip.cpp +++ b/src/fs/virtfs/virtfszip.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/virtfszip.h" #include "fs/virtfsfuncs.h" @@ -340,4 +338,3 @@ namespace VirtFsZip return file->mPrivate->mPos >= file->mPrivate->mSize; } } // namespace VirtFsZip -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtfszip.h b/src/fs/virtfs/virtfszip.h index f615e38fd..9094f9eba 100644 --- a/src/fs/virtfs/virtfszip.h +++ b/src/fs/virtfs/virtfszip.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTFSZIP_H #define UTILS_VIRTFSZIP_H -#ifndef USE_PHYSFS #include "utils/stringvector.h" @@ -74,5 +73,4 @@ namespace VirtFsZip int eof(VirtFile *restrict const file); } // namespace VirtFsZip -#endif // USE_PHYSFS #endif // UTILS_VIRTFSZIP_H diff --git a/src/fs/virtfs/virtzipentry.cpp b/src/fs/virtfs/virtzipentry.cpp index 216603bed..c832578bd 100644 --- a/src/fs/virtfs/virtzipentry.cpp +++ b/src/fs/virtfs/virtzipentry.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/virtzipentry.h" #include "fs/virtfs/ziplocalheader.h" @@ -41,4 +39,3 @@ VirtZipEntry::~VirtZipEntry() { delete_all(mHeaders); } -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/virtzipentry.h b/src/fs/virtfs/virtzipentry.h index 6487deeb0..d3c69aa36 100644 --- a/src/fs/virtfs/virtzipentry.h +++ b/src/fs/virtfs/virtzipentry.h @@ -20,7 +20,6 @@ #ifndef UTILS_VIRTZIPENTRY_H #define UTILS_VIRTZIPENTRY_H -#ifndef USE_PHYSFS #include "fs/virtfs/virtfsentry.h" @@ -43,5 +42,4 @@ struct VirtZipEntry final : public VirtFsEntry std::vector<std::string> mDirs; }; -#endif // USE_PHYSFS #endif // UTILS_VIRTZIPENTRY_H diff --git a/src/fs/virtfs/zip.cpp b/src/fs/virtfs/zip.cpp index c9276449b..330850aee 100644 --- a/src/fs/virtfs/zip.cpp +++ b/src/fs/virtfs/zip.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/zip.h" #include "fs/paths.h" @@ -321,4 +319,3 @@ namespace Zip return out; } } // namespace Zip -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/zip.h b/src/fs/virtfs/zip.h index 8efbd05e4..89e04408f 100644 --- a/src/fs/virtfs/zip.h +++ b/src/fs/virtfs/zip.h @@ -20,7 +20,6 @@ #ifndef UTILS_ZIP_H #define UTILS_ZIP_H -#ifndef USE_PHYSFS #include "localconsts.h" @@ -39,5 +38,4 @@ namespace Zip uint8_t *readFile(const ZipLocalHeader *restrict const header); } // namespace Zip -#endif // USE_PHYSFS #endif // UTILS_ZIP_H diff --git a/src/fs/virtfs/zip_unittest.cc b/src/fs/virtfs/zip_unittest.cc index 27d4bc1f9..401768b7c 100644 --- a/src/fs/virtfs/zip_unittest.cc +++ b/src/fs/virtfs/zip_unittest.cc @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "catch.hpp" #include "logger.h" @@ -296,4 +294,3 @@ TEST_CASE("Zip readFile") delete2(logger); } -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/ziplocalheader.cpp b/src/fs/virtfs/ziplocalheader.cpp index 40ddcaffd..47ed4d290 100644 --- a/src/fs/virtfs/ziplocalheader.cpp +++ b/src/fs/virtfs/ziplocalheader.cpp @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef USE_PHYSFS - #include "fs/virtfs/ziplocalheader.h" #include "localconsts.h" @@ -35,4 +33,3 @@ ZipLocalHeader::ZipLocalHeader() : compressed(false) { } -#endif // USE_PHYSFS diff --git a/src/fs/virtfs/ziplocalheader.h b/src/fs/virtfs/ziplocalheader.h index 2ec781858..f3a1894ce 100644 --- a/src/fs/virtfs/ziplocalheader.h +++ b/src/fs/virtfs/ziplocalheader.h @@ -20,7 +20,6 @@ #ifndef UTILS_ZIPLOCALHEADER_H #define UTILS_ZIPLOCALHEADER_H -#ifndef USE_PHYSFS #include "localconsts.h" @@ -42,5 +41,4 @@ struct ZipLocalHeader final bool compressed; }; -#endif // USE_PHYSFS #endif // UTILS_ZIPLOCALHEADER_H diff --git a/src/fs/virtfsfuncs.h b/src/fs/virtfsfuncs.h index ad5f6c387..46bcd86ff 100644 --- a/src/fs/virtfsfuncs.h +++ b/src/fs/virtfsfuncs.h @@ -26,9 +26,7 @@ #include "localconsts.h" struct VirtFile; -#ifndef USE_PHYSFS struct VirtFsEntry; -#endif // USE_PHYSFS struct VirtFsFuncs final { @@ -39,7 +37,6 @@ struct VirtFsFuncs final fileLength(nullptr), tell(nullptr), seek(nullptr), -#ifndef USE_PHYSFS exists(nullptr), getRealDir(nullptr), enumerate(nullptr), @@ -47,7 +44,6 @@ struct VirtFsFuncs final openRead(nullptr), openWrite(nullptr), openAppend(nullptr), -#endif eof(nullptr) { } @@ -67,7 +63,6 @@ struct VirtFsFuncs final int64_t (*tell) (VirtFile *restrict const file); int (*seek) (VirtFile *restrict const file, const uint64_t pos); -#ifndef USE_PHYSFS bool (*exists) (VirtFsEntry *restrict const entry, const std::string &filename, const std::string &dirName); @@ -87,7 +82,6 @@ struct VirtFsFuncs final const std::string &filename); VirtFile *(*openAppend) (VirtFsEntry *restrict const entry, const std::string &filename); -#endif // USE_PHYSFS int (*eof) (VirtFile *restrict const file); }; diff --git a/src/fs/virtfsrwops.cpp b/src/fs/virtfsrwops.cpp index 036d8bb60..adb6fe0ea 100644 --- a/src/fs/virtfsrwops.cpp +++ b/src/fs/virtfsrwops.cpp @@ -431,4 +431,4 @@ void VirtFs::reportRWops() } #endif // DUMP_LEAKED_RESOURCES -/* end of physfsrwops.c ... */ +/* end of virtfsrwops.c ... */ diff --git a/src/fs/virtfsrwops.h b/src/fs/virtfsrwops.h index 82bb740de..2703044df 100644 --- a/src/fs/virtfsrwops.h +++ b/src/fs/virtfsrwops.h @@ -42,8 +42,8 @@ * Copyright (C) 2012-2017 The ManaPlus Developers */ -#ifndef UTILS_PHYSFSRWOPS_H -#define UTILS_PHYSFSRWOPS_H +#ifndef SRC_FS_VIRTFSRWOPS_H +#define SRC_FS_VIRTFSRWOPS_H #include "localconsts.h" @@ -72,4 +72,4 @@ namespace VirtFs #endif // DUMP_LEAKED_RESOURCES } // namespace VirtFs -#endif // UTILS_PHYSFSRWOPS_H +#endif // SRC_FS_VIRTFSRWOPS_H diff --git a/src/integrity_unittest.cc b/src/integrity_unittest.cc index fd01ce171..2d8a57a04 100644 --- a/src/integrity_unittest.cc +++ b/src/integrity_unittest.cc @@ -46,24 +46,10 @@ #include "utils/env.h" #include "utils/delete2.h" -#ifdef USE_PHYSFS -PRAGMA45(GCC diagnostic push) -PRAGMA45(GCC diagnostic ignored "-Wlong-long") -#include <physfs.h> -PRAGMA45(GCC diagnostic pop) -#endif // USE_PHYSFS #include <SDL_image.h> #include "debug.h" -#ifdef USE_SDL2 -#define PHYSFSINT int64_t -#define PHYSFSSIZE size_t -#else // USE_SDL2 -#define PHYSFSINT int32_t -#define PHYSFSSIZE int -#endif // USE_SDL2 - namespace { class InputActionSortFunctorTest final @@ -266,155 +252,6 @@ TEST_CASE("integrity tests", "integrity") VirtFs::unmountDirSilent(prefix + "data/test"); } -#ifdef USE_PHYSFS - SECTION("integrity Loader::getImage test 5") - { - VirtFs::mountZip("data/test/test.zip", Append_false); - VirtFs::mountZip("../data/test/test.zip", Append_false); - - PHYSFS_file *handle = PHYSFS_openRead(name1); - REQUIRE(handle != nullptr); -// int64_t seek = rw->seek(rw, 0, RW_SEEK_END); - const PHYSFS_sint64 len = PHYSFS_fileLength(handle); - REQUIRE(len == size1); - PHYSFSINT pos = static_cast<PHYSFSINT>(len); - REQUIRE(static_cast<PHYSFS_sint64>(pos) == len); - REQUIRE(pos >= 0); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(pos)) != 0); - int64_t seek = pos; - - REQUIRE(seek != -1); - -// const int64_t pos1 = rw->seek(rw, 0, RW_SEEK_CUR); - const PHYSFS_sint64 current = PHYSFS_tell(handle); - REQUIRE(current != -1); - REQUIRE(current == size1); - pos = CAST_S32(current); - REQUIRE(static_cast<PHYSFS_sint64>(pos) == current); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(pos)) != 0); - const int64_t pos1 = pos; - - REQUIRE(pos1 == size1); - -// seek = rw->seek(rw, 0, RW_SEEK_SET); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(0)) != 0); - seek = 0; - - REQUIRE(seek != -1); - - unsigned char buf[size1]; - -// const size_t sz = rw->read(rw, buf, 1, pos1); - const PHYSFS_sint64 rc = PHYSFS_read(handle, buf, - CAST_U32(1), - CAST_U32(size1)); - if (rc != static_cast<PHYSFS_sint64>(size1)) - { - logger->log("PHYSFS_read %d bytes", static_cast<int>(rc)); - if (!PHYSFS_eof(handle)) - { - logger->log("PhysicsFS read error: %s", - PHYSFS_getLastError()); - } -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - } - const size_t sz = rc; - REQUIRE(sz == size1); - -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - - VirtFs::unmountZip("data/test/test.zip"); - VirtFs::unmountZip("../data/test/test.zip"); - } - - SECTION("integrity Loader::getImage test 6") - { - VirtFs::mountZip("data/test/test.zip", Append_false); - VirtFs::mountZip("../data/test/test.zip", Append_false); - - PHYSFS_file *handle = PHYSFS_openRead(name1); - REQUIRE(handle != nullptr); -// int64_t seek = rw->seek(rw, 0, RW_SEEK_END); - const PHYSFS_sint64 len = PHYSFS_fileLength(handle); - PHYSFSINT pos = static_cast<PHYSFSINT>(len); - REQUIRE(static_cast<PHYSFS_sint64>(pos) == len); - REQUIRE(pos >= 0); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(pos)) != 0); - int64_t seek = pos; - - if (seek == -1) - { -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - } - REQUIRE(seek != -1); - -// const int64_t pos1 = rw->seek(rw, 0, RW_SEEK_CUR); - const PHYSFS_sint64 current = PHYSFS_tell(handle); - REQUIRE(current != -1); - pos = CAST_S32(current); - REQUIRE(static_cast<PHYSFS_sint64>(pos) == current); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(pos)) != 0); - const int64_t pos1 = pos; - - if (pos1 != size1) - { -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - } - REQUIRE(pos1 == size1); - -// seek = rw->seek(rw, 0, RW_SEEK_SET); - REQUIRE(PHYSFS_seek(handle, static_cast<PHYSFS_uint64>(0)) != 0); - seek = 0; - - if (seek == -1) - { -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - } - REQUIRE(seek != -1); - - unsigned char buf[size1]; - -// const size_t sz = rw->read(rw, buf, 1, pos1); - const PHYSFS_sint64 rc = PHYSFS_read(handle, buf, - CAST_U32(1), - CAST_U32(pos1)); - if (rc != static_cast<PHYSFS_sint64>(pos1)) - { - if (!PHYSFS_eof(handle)) - { - logger->log("PhysicsFS read error1: %s", - PHYSFS_getLastError()); - } - } - const size_t sz = rc; - - if (sz != size1) - { -// rw->close(rw); - logger->log("PhysicsFS read error2: %s", - PHYSFS_getLastError()); - REQUIRE(PHYSFS_close(handle) != 0); - } - REQUIRE(sz == size1); - -// rw->close(rw); - REQUIRE(PHYSFS_close(handle) != 0); - - VirtFs::unmountZip("data/test/test.zip"); - VirtFs::unmountZip("../data/test/test.zip"); - VirtFs::mountDirSilent("data/test", Append_true); - VirtFs::mountDirSilent("../data/test", Append_true); - REQUIRE(compareBuffers(buf)); - VirtFs::unmountDirSilent("data/test"); - VirtFs::unmountDirSilent("../data/test"); - } -#endif // USE_PHYSFS - SECTION("integrity Loader::getImage test 7") { VirtFs::mountZip(prefix + "data/test/test.zip", Append_false); diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp index 46894b24b..768b6db7e 100644 --- a/src/resources/atlas/atlasmanager.cpp +++ b/src/resources/atlas/atlasmanager.cpp @@ -167,10 +167,6 @@ void AtlasManager::loadImages(const StringVect &files, images.push_back(image); } } - else - { - reportAlways("Physfs error: %s", VirtFs::getLastError()); - } delete d; } BLOCK_END("AtlasManager::loadImages") diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp index 3a4909d94..e141afa2d 100644 --- a/src/resources/loaders/imageloader.cpp +++ b/src/resources/loaders/imageloader.cpp @@ -69,7 +69,6 @@ namespace { delete d; reportAlways("Image loading error: %s", path1.c_str()); - reportAlways("Physfs error: %s", VirtFs::getLastError()); BLOCK_END("DyedImageLoader::load") return nullptr; } diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp index ee464ae48..bb1415dcc 100644 --- a/src/resources/loaders/musicloader.cpp +++ b/src/resources/loaders/musicloader.cpp @@ -50,7 +50,6 @@ namespace SDL_RWops *const rw = VirtFs::RWopsOpenRead(rl->path); if (!rw) { - reportAlways("Physfs error: %s", VirtFs::getLastError()); reportAlways("Error loading resource: %s", rl->path.c_str()); return nullptr; diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp index cbc0cbde9..93e7c38f9 100644 --- a/src/resources/loaders/soundloader.cpp +++ b/src/resources/loaders/soundloader.cpp @@ -50,7 +50,6 @@ namespace SDL_RWops *const rw = VirtFs::RWopsOpenRead(rl->path); if (!rw) { - reportAlways("Physfs error: %s", VirtFs::getLastError()); reportAlways("Error loading resource: %s", rl->path.c_str()); return nullptr; diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp index b53a6c753..40e558e4c 100644 --- a/src/utils/dumplibs.cpp +++ b/src/utils/dumplibs.cpp @@ -32,12 +32,6 @@ PRAGMACLANG6(GCC diagnostic ignored "-Wold-style-cast") #include <SDL_net.h> PRAGMACLANG6(GCC diagnostic pop) #include <SDL_ttf.h> -#ifdef USE_PHYSFS -PRAGMA45(GCC diagnostic push) -PRAGMA45(GCC diagnostic ignored "-Wlong-long") -#include <physfs.h> -PRAGMA45(GCC diagnostic pop) -#endif // USE_PHYSFS #include <zlib.h> #include <curl/curl.h> @@ -120,15 +114,6 @@ void dumpLibs() logger->log(" libcurl: %s", LIBCURL_VERSION); logger->log(" libpng: %s", PNG_LIBPNG_VER_STRING); -#ifdef USE_PHYSFS - PHYSFS_Version physfsVersion; - PHYSFS_VERSION(&physfsVersion); - const std::string physfsCompiled = strprintf("%d.%d.%d", - physfsVersion.major, - physfsVersion.minor, - physfsVersion.patch); - logger->log(" libphysfs: %s", physfsCompiled.c_str()); -#endif // USE_PHYSFS dumpCompiledSdlVersion("SDL", SDL); dumpCompiledSdlVersion("SDL_net", SDL_NET); @@ -140,14 +125,6 @@ void dumpLibs() #if ZLIB_VERNUM >= 0x1020 logger->log(" zLib: %s", zlibVersion()); #endif // ZLIB_VERNUM >= 0x1020 -#ifdef USE_PHYSFS - PHYSFS_getLinkedVersion(&physfsVersion); - const std::string physfsLinked = strprintf("%d.%d.%d", - physfsVersion.major, - physfsVersion.minor, - physfsVersion.patch); - logger->log(" libphysfs: %s", physfsLinked.c_str()); -#endif // USE_PHYSFS #ifdef LIBXML_TEST_VERSION LIBXML_TEST_VERSION #endif // LIBXML_TEST_VERSION @@ -167,9 +144,6 @@ void dumpLibs() dumpLinkedSdlVersion("SDL_ttf", TTF_Linked_Version()); compareVersions("zLib", ZLIB_VERSION, zlibVersion()); -#ifdef USE_PHYSFS - compareVersions("libphysfs", physfsCompiled.c_str(), physfsLinked.c_str()); -#endif // USE_PHYSFS #ifdef USE_SDL2 compareSDLVersions("SDL", sdlVersionJoin(SDL), &sdlVersion); #else // USE_SDL2 diff --git a/src/utils/dumplibs_unittest.cc b/src/utils/dumplibs_unittest.cc index 4d0f55c7d..1833fe714 100644 --- a/src/utils/dumplibs_unittest.cc +++ b/src/utils/dumplibs_unittest.cc @@ -31,12 +31,6 @@ PRAGMACLANG6(GCC diagnostic ignored "-Wold-style-cast") #include <SDL_net.h> PRAGMACLANG6(GCC diagnostic pop) #include <SDL_ttf.h> -#ifdef USE_PHYSFS -PRAGMA45(GCC diagnostic push) -PRAGMA45(GCC diagnostic ignored "-Wlong-long") -#include <physfs.h> -PRAGMA45(GCC diagnostic pop) -#endif // USE_PHYSFS #include <zlib.h> #include "debug.h" @@ -52,27 +46,6 @@ TEST_CASE("dumplibs tests") REQUIRE(build == link); } -#ifdef USE_PHYSFS - SECTION("physfs") - { - PHYSFS_Version buildVersion; - PHYSFS_Version linkVersion; - PHYSFS_VERSION(&buildVersion); - PHYSFS_getLinkedVersion(&linkVersion); - - const std::string build = strprintf("%d.%d.%d", - buildVersion.major, - buildVersion.minor, - buildVersion.patch); - const std::string link = strprintf("%d.%d.%d", - linkVersion.major, - linkVersion.minor, - linkVersion.patch); - - REQUIRE(build == link); - } -#endif // USE_PHYSFS - SECTION("sdl") { const SDL_version *linkVersion = nullptr; diff --git a/tools/ci/scripts/deheader.sh b/tools/ci/scripts/deheader.sh index e221951a7..4e142679b 100755 --- a/tools/ci/scripts/deheader.sh +++ b/tools/ci/scripts/deheader.sh @@ -15,7 +15,6 @@ ${dir}/deheader -q -i "\"debug.h\"" \ -i "\"sdlshared.h\"" \ -i "\"localconsts.h\"" \ -i "\"utils/fuzzer.h\"" \ --i "\"utils/physfscheckutils.h\"" \ -i "\"$name\"" \ -c "$CXX" \ -d "$FLAGS" \ |