1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +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

@ -15,6 +15,7 @@
#include "CCompressedStream.h"
#include "CBinaryReader.h"
#include "../texts/TextOperations.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -240,6 +241,19 @@ void CArchiveLoader::extractToFolder(const std::string & outputSubFolder, const
extractToFolder(outputSubFolder, *inputStream, entry, absolute);
}
std::string CArchiveLoader::getFullFileURI(const ResourcePath& resourceName) const
{
auto relativePath = TextOperations::Utf8TofilesystemPath(resourceName.getName());
auto path = boost::filesystem::canonical(archive) / relativePath;
return TextOperations::filesystemPathToUtf8(path);
}
std::time_t CArchiveLoader::getLastWriteTime(const ResourcePath& resourceName) const
{
return boost::filesystem::last_write_time(archive);
}
boost::filesystem::path createExtractedFilePath(const std::string & outputSubFolder, const std::string & entryName, bool absolute)
{
boost::filesystem::path extractionFolderPath = absolute ? outputSubFolder : VCMIDirs::get().userExtractedPath() / outputSubFolder;