1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

fix crash when map is packaged in a zip mod

This commit is contained in:
kdmcser
2025-05-16 01:14:12 +08:00
parent 29207c0b0f
commit 5e4912d056
11 changed files with 94 additions and 11 deletions

View File

@ -11,6 +11,7 @@
#include "CZipLoader.h"
#include "../ScopeGuard.h"
#include "../texts/TextOperations.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -120,6 +121,19 @@ std::unordered_set<ResourcePath> CZipLoader::getFilteredFiles(std::function<bool
return foundID;
}
std::string CZipLoader::getFullFileURI(const ResourcePath& resourceName) const
{
auto relativePath = TextOperations::Utf8TofilesystemPath(resourceName.getName());
auto path = boost::filesystem::canonical(archiveName) / relativePath;
return TextOperations::filesystemPathToUtf8(path);
}
std::time_t CZipLoader::getLastWriteTime(const ResourcePath& resourceName) const
{
auto path = boost::filesystem::canonical(archiveName);
return boost::filesystem::last_write_time(path);
}
/// extracts currently selected file from zip into stream "where"
static bool extractCurrent(unzFile file, std::ostream & where)
{