Nicer logging if no texture.zip file is there

This commit is contained in:
Henrik Rydgård committed 2023-03-16 22:59:26 +01:00
1 parent 2f1441eceb
commit 8484dd4917
3 files changed
+12 -5

No files matched your search

+7 -3
View File
@@ -15,13 +15,15 @@
#include "Common/File/VFS/ZipFileReader.h"
#include "Common/StringUtils.h"
ZipFileReader *ZipFileReader::Create(const Path &zipFile, const char *inZipPath) {
ZipFileReader *ZipFileReader::Create(const Path &zipFile, const char *inZipPath, bool logErrors) {
int error = 0;
zip *zip_file;
if (zipFile.Type() == PathType::CONTENT_URI) {
int fd = File::OpenFD(zipFile, File::OPEN_READ);
if (!fd) {
ERROR_LOG(IO, "Failed to open FD for %s as zip file", zipFile.c_str());
if (logErrors) {
ERROR_LOG(IO, "Failed to open FD for '%s' as zip file", zipFile.c_str());
}
return nullptr;
}
zip_file = zip_fdopen(fd, 0, &error);
@@ -30,7 +32,9 @@ ZipFileReader *ZipFileReader::Create(const Path &zipFile, const char *inZipPath)
}
if (!zip_file) {
ERROR_LOG(IO, "Failed to open %s as a zip file", zipFile.c_str());
if (logErrors) {
ERROR_LOG(IO, "Failed to open %s as a zip file", zipFile.c_str());
}
return nullptr;
}
+1 -1
View File
@@ -16,7 +16,7 @@
class ZipFileReader : public VFSBackend {
public:
static ZipFileReader *Create(const Path &zipFile, const char *inZipPath);
static ZipFileReader *Create(const Path &zipFile, const char *inZipPath, bool logErrors = true);
~ZipFileReader();
bool IsValid() const { return zip_file_ != nullptr; }
+4 -1
View File
@@ -124,9 +124,12 @@ bool TextureReplacer::LoadIni() {
delete vfs_;
vfs_ = nullptr;
Path zipPath = basePath_ / ZIP_FILENAME;
// First, check for textures.zip, which is used to reduce IO.
VFSBackend *dir = ZipFileReader::Create(basePath_ / ZIP_FILENAME, "");
VFSBackend *dir = ZipFileReader::Create(zipPath, "", false);
if (!dir) {
INFO_LOG(G3D, "%s wasn't a zip file - opening the directory %s instead.", zipPath.c_str(), basePath_.c_str());
vfsIsZip_ = false;
dir = new DirectoryReader(basePath_);
} else {