From 54aaa51736c673d05557b5dfbbac2dcb273a1829 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Feb 2016 10:22:47 +0100 Subject: [PATCH] Fixed: patch_gen is now using packLZMA function to compress a file instead of using lzma executable --- code/ryzom/tools/patch_gen/CMakeLists.txt | 6 ++-- .../tools/patch_gen/patch_gen_common.cpp | 34 ++++--------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/code/ryzom/tools/patch_gen/CMakeLists.txt b/code/ryzom/tools/patch_gen/CMakeLists.txt index d7d864f9a..6cde9810b 100644 --- a/code/ryzom/tools/patch_gen/CMakeLists.txt +++ b/code/ryzom/tools/patch_gen/CMakeLists.txt @@ -1,13 +1,15 @@ +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ryzom/client/src/seven_zip) + SET(MAIN_SRC patch_gen_common.cpp patch_gen_main.cpp patch_gen_main.h) SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h) ADD_EXECUTABLE(patch_gen ${MAIN_SRC}) -TARGET_LINK_LIBRARIES(patch_gen ryzom_gameshare nelmisc nelnet nelligo nelgeorges) +TARGET_LINK_LIBRARIES(patch_gen ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) NL_DEFAULT_PROPS(patch_gen "Ryzom, Tools: Patch Generator") NL_ADD_RUNTIME_FLAGS(patch_gen) ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC}) -TARGET_LINK_LIBRARIES(patch_gen_service ryzom_gameshare nelmisc nelnet nelligo nelgeorges) +TARGET_LINK_LIBRARIES(patch_gen_service ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) NL_DEFAULT_PROPS(patch_gen_service "Ryzom, Tools: Patch Generator Service") NL_ADD_RUNTIME_FLAGS(patch_gen_service) diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index dd4bf4211..c1290cfd5 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -27,6 +27,7 @@ #include "nel/misc/command.h" #include "nel/misc/sstring.h" #include "game_share/singleton_registry.h" +#include "seven_zip.h" using namespace std; using namespace NLMISC; @@ -74,37 +75,16 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c #endif // NL_OS_WINDOWS } -void GenerateLZMA(const std::string sourceFile, const std::string &outputFile) +void GenerateLZMA(const std::string &sourceFile, const std::string &outputFile) { { - // old syntax incompatible with new versions - std::string cmd = "lzma e"; - cmd += " " + sourceFile + " " + outputFile; - nlinfo("Executing system command: %s", cmd.c_str()); + nlinfo("Compressing %s to %s using LZMA...", sourceFile.c_str(), outputFile.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 - // new lzma only supports one file name on command line, so make a copy - CFile::copyFile(outputFile, sourceFile); - // 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) + if (!packLZMA(sourceFile, outputFile)) { - nlwarning("'%s' failed with error code %d", cmd.c_str(), error); - - CFile::deleteFile(outputFile); + nlwarning("LZMA compress failed"); } - else - { - // lzma always append a .lzma extension, so rename compressed file to wanted one - CFile::moveFile(outputFile, outputFile + ".lzma"); - } -#endif // NL_OS_WINDOWS } @@ -230,7 +210,7 @@ void CPackageDescription::storeToPdr(CPersistentDataRecord& pdr) const void CPackageDescription::readIndex(CBNPFileSet& packageIndex) const { std::string indexPath = _RootDirectory + _IndexFileName; - + nlinfo("Reading history file: %s ...", indexPath.c_str()); // clear out old contents before reading from input file @@ -294,7 +274,7 @@ void CPackageDescription::generateClientIndex(CProductDescriptionForClient& theC std::string patchNumber = toString("%05u", packageIndex.getVersionNumber()); std::string patchDirectory = _PatchDirectory + patchNumber; std::string patchFile = patchDirectory + "/" + _ClientIndexFileName; - + nlinfo("Generating client index: %s...", patchFile.c_str()); // make sure the version sub directory exist