mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-26 16:56:19 +00:00
Fixed: patch_gen is now using packLZMA function to compress a file instead of using lzma executable
This commit is contained in:
parent
92c598c81e
commit
54aaa51736
2 changed files with 11 additions and 29 deletions
|
@ -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(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)
|
SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h)
|
||||||
|
|
||||||
ADD_EXECUTABLE(patch_gen ${MAIN_SRC})
|
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_DEFAULT_PROPS(patch_gen "Ryzom, Tools: Patch Generator")
|
||||||
NL_ADD_RUNTIME_FLAGS(patch_gen)
|
NL_ADD_RUNTIME_FLAGS(patch_gen)
|
||||||
|
|
||||||
ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC})
|
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_DEFAULT_PROPS(patch_gen_service "Ryzom, Tools: Patch Generator Service")
|
||||||
NL_ADD_RUNTIME_FLAGS(patch_gen_service)
|
NL_ADD_RUNTIME_FLAGS(patch_gen_service)
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "nel/misc/command.h"
|
#include "nel/misc/command.h"
|
||||||
#include "nel/misc/sstring.h"
|
#include "nel/misc/sstring.h"
|
||||||
#include "game_share/singleton_registry.h"
|
#include "game_share/singleton_registry.h"
|
||||||
|
#include "seven_zip.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
@ -74,37 +75,16 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c
|
||||||
#endif // NL_OS_WINDOWS
|
#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
|
nlinfo("Compressing %s to %s using LZMA...", sourceFile.c_str(), outputFile.c_str());
|
||||||
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
|
|
||||||
// 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
|
if (!packLZMA(sourceFile, outputFile))
|
||||||
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);
|
nlwarning("LZMA compress failed");
|
||||||
|
|
||||||
CFile::deleteFile(outputFile);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// lzma always append a .lzma extension, so rename compressed file to wanted one
|
|
||||||
CFile::moveFile(outputFile, outputFile + ".lzma");
|
|
||||||
}
|
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue