diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index 57f30b5fe..0e8831828 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -76,15 +76,34 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c void GenerateLZMA(const std::string sourceFile, const std::string &outputFile) { - std::string cmd="lzma e "; - cmd+=" "+sourceFile+" "+outputFile; - nlinfo("executing system command: %s",cmd.c_str()); + { + // old syntax incompatible with new versions + std::string cmd = "lzma e "; + cmd += " " + sourceFile + " " + outputFile; + nlinfo("Executing system command: %s", cmd.c_str()); + } #ifdef NL_OS_WINDOWS _spawnlp(_P_WAIT, "lzma.exe","lzma.exe", "e", sourceFile.c_str(), outputFile.c_str(), NULL); #else // NL_OS_WINDOWS - sint error = system (cmd.c_str()); + // new lzma only supports one file name on command line, so make a copy + CFile::copyFile(sourceFile, outputFile); + + // new lzma syntax, -z = compress, -9 = best compression + std::string cmd = NLMISC::toString("lzma -z -9 %s", outputFile.c_str()); + + sint error = system(cmd.c_str()); + if (error) + { nlwarning("'%s' failed with error code %d", cmd.c_str(), error); + + CFile::deleteFile(outputFile); + } + else + { + // lzma always append a .lzma extension, so rename compressed file to wanted one + CFile::moveFile(outputFile + ".lzma", outputFile); + } #endif // NL_OS_WINDOWS }