mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-24 20:12:15 +00:00
Fix loading tpf contents with password
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user