diff --git a/src/modules/filesystem/physfs/File.cpp b/src/modules/filesystem/physfs/File.cpp index e378f28c4..fafd7caab 100644 --- a/src/modules/filesystem/physfs/File.cpp +++ b/src/modules/filesystem/physfs/File.cpp @@ -72,11 +72,7 @@ bool File::open(Mode mode) if (file != nullptr) return false; -#ifdef LOVE_USE_PHYSFS_2_1 PHYSFS_getLastErrorCode(); -#else - PHYSFS_getLastError(); // Clear the error buffer. -#endif PHYSFS_File *handle = nullptr; switch (mode) @@ -96,11 +92,7 @@ bool File::open(Mode mode) if (handle == nullptr) { -#ifdef LOVE_USE_PHYSFS_2_1 const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); -#else - const char *err = PHYSFS_getLastError(); -#endif if (err == nullptr) err = "unknown error"; throw love::Exception("Could not open file %s (%s)", filename.c_str(), err); @@ -163,15 +155,7 @@ int64 File::read(void *dst, int64 size) if (size < 0) throw love::Exception("Invalid read size."); -#ifdef LOVE_USE_PHYSFS_2_1 - int64 read = PHYSFS_readBytes(file, dst, (PHYSFS_uint64) size); -#else - // Sadly, we'll have to clamp to 32 bits here - size = (size > LOVE_UINT32_MAX) ? LOVE_UINT32_MAX : size; - int64 read = (int64)PHYSFS_read(file, dst, 1, (PHYSFS_uint32) size); -#endif - - return read; + return PHYSFS_readBytes(file, dst, (PHYSFS_uint64) size); } bool File::write(const void *data, int64 size) @@ -183,13 +167,7 @@ bool File::write(const void *data, int64 size) throw love::Exception("Invalid write size."); // Try to write. -#ifdef LOVE_USE_PHYSFS_2_1 int64 written = PHYSFS_writeBytes(file, data, (PHYSFS_uint64) size); -#else - // Another clamp, for the time being. - size = (size > LOVE_UINT32_MAX) ? LOVE_UINT32_MAX : size; - int64 written = (int64) PHYSFS_write(file, data, 1, (PHYSFS_uint32) size); -#endif // Check that correct amount of data was written. if (written != size) diff --git a/src/modules/filesystem/physfs/File.h b/src/modules/filesystem/physfs/File.h index 4e8dc17e3..ec5081b5c 100644 --- a/src/modules/filesystem/physfs/File.h +++ b/src/modules/filesystem/physfs/File.h @@ -31,10 +31,6 @@ // STD #include -#if PHYSFS_VER_MAJOR > 2 || (PHYSFS_VER_MAJOR == 2 && PHYSFS_VER_MINOR >= 1) -#define LOVE_USE_PHYSFS_2_1 -#endif - namespace love { namespace filesystem diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index a5d429bb5..087f24aae 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -120,16 +120,9 @@ const char *Filesystem::getName() const void Filesystem::init(const char *arg0) { if (!PHYSFS_init(arg0)) - { -#ifdef LOVE_USE_PHYSFS_2_1 - const char *err = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()); -#else - const char *err = PHYSFS_getLastError(); -#endif - throw love::Exception("%s", err); - } + throw love::Exception("%s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); - // Enable symlinks by default. Also fixes an issue in PhysFS 2.1-alpha. + // Enable symlinks by default. setSymlinksEnabled(true); } @@ -197,13 +190,7 @@ bool Filesystem::setIdentity(const char *ident, bool appendToPath) // We don't want old read-only save paths to accumulate when we set a new // identity. if (!old_save_path.empty()) - { -#ifdef LOVE_USE_PHYSFS_2_1 PHYSFS_unmount(old_save_path.c_str()); -#else - PHYSFS_removeFromSearchPath(old_save_path.c_str()); -#endif - } // Try to add the save directory to the search path. // (No error on fail, it means that the path doesn't exist). @@ -448,11 +435,7 @@ bool Filesystem::unmount(const char *archive) if (!mountPoint) return false; -#ifdef LOVE_USE_PHYSFS_2_1 return PHYSFS_unmount(realPath.c_str()) != 0; -#else - return PHYSFS_removeFromSearchPath(realPath.c_str()) != 0; -#endif } love::filesystem::File *Filesystem::newFile(const char *filename) const @@ -564,7 +547,7 @@ std::string Filesystem::getRealDirectory(const char *filename) const const char *dir = PHYSFS_getRealDir(filename); if (dir == nullptr) - throw love::Exception("File does not exist."); + throw love::Exception("File does not exist on disk."); return std::string(dir); } @@ -574,7 +557,6 @@ bool Filesystem::getInfo(const char *filepath, Info &info) const if (!PHYSFS_isInit()) return false; -#ifdef LOVE_USE_PHYSFS_2_1 PHYSFS_Stat stat = {}; if (!PHYSFS_stat(filepath, &stat)) return false; @@ -590,30 +572,6 @@ bool Filesystem::getInfo(const char *filepath, Info &info) const info.type = FILETYPE_SYMLINK; else info.type = FILETYPE_OTHER; -#else - if (!PHYSFS_exists(filepath)) - return false; - - try - { - File file(filepath); - info.size = file.getSize(); - } - catch (love::Exception &) - { - info.size = -1; - } - - info.modtime = (int64) PHYSFS_getLastModTime(filepath); - - if (PHYSFS_isSymbolicLink(filepath)) - info.type = FILETYPE_SYMLINK; - else if (PHYSFS_isDirectory(filepath)) - info.type = FILETYPE_DIRECTORY; - else - info.type = FILETYPE_FILE; - -#endif return true; } @@ -699,17 +657,6 @@ void Filesystem::setSymlinksEnabled(bool enable) if (!PHYSFS_isInit()) return; - if (!enable) - { - PHYSFS_Version version = {}; - PHYSFS_getLinkedVersion(&version); - - // FIXME: This is a workaround for a bug in PHYSFS_enumerateFiles in - // PhysFS 2.1.0-alpha. - if (version.major == 2 && version.minor == 1 && version.patch == 0) - return; - } - PHYSFS_permitSymbolicLinks(enable ? 1 : 0); } diff --git a/src/modules/graphics/Image.cpp b/src/modules/graphics/Image.cpp index 3c3772d2e..22f535a45 100644 --- a/src/modules/graphics/Image.cpp +++ b/src/modules/graphics/Image.cpp @@ -333,7 +333,7 @@ Image::MipmapsType Image::Slices::validate() const if (textureType == TEXTURE_VOLUME) mipslices = std::max(mipslices / 2, 1); } - + if (mipcount > 1) return MIPMAPS_DATA; else