From db9f889662b4a1e662e52df37964dd877dc7633f Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 13 Dec 2015 13:19:55 +0100 Subject: [PATCH] Fixed: New LZMA syntax under Linux --- .../tools/patch_gen/patch_gen_common.cpp | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) 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 }