Fix loading tpf contents with password

This commit is contained in:
2023-11-17 12:51:28 +01:00
parent b9ce5908e9
commit a1497fff5c
2 changed files with 32 additions and 12 deletions
+5 -5
View File
@@ -33,14 +33,14 @@ std::vector<TpfEntry> gMod_FileLoader::GetTpfContents()
try {
auto istream = std::ifstream(file_name, std::ios::binary);
auto xorstream = gMod_XorStream(istream);
const auto buffer = xorstream.ReadToEnd();
const std::string password(TPF_PASSWORD.begin(), TPF_PASSWORD.end());
libzippp::ZipArchive zipArchive(file_name, password);
zipArchive.setErrorHandlerCallback([](const std::string& message, const std::string& strerror, int zip_error_code, int system_error_code) -> void {
auto zipArchive = libzippp::ZipArchive::fromBuffer(buffer.data(), buffer.size(), false, password);
zipArchive->setErrorHandlerCallback([](const std::string& message, const std::string& strerror, int zip_error_code, int system_error_code) -> void {
Message("GetTpfContents: %s %s %d %d\n", message.c_str(), strerror.c_str(), zip_error_code, system_error_code);
});
zipArchive.open();
LoadEntries(zipArchive, entries);
zipArchive->open();
LoadEntries(*zipArchive, entries);
}
catch (const std::exception& e) {
throw std::runtime_error("Failed to open zip file: " + file_name + "\n" + e.what());