mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-02 16:24:47 +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
6f6888324f
commit
690fa0b2e1
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(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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue