From ae94fb3f1a9027cec1156e35cb0508849d007fae Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 14 Jun 2016 22:58:23 +0200 Subject: [PATCH 1/3] Fixed: xdelta 1.x returns 2 when an error occurs (0 or 1 is a success) --HG-- branch : develop --- code/ryzom/tools/patch_gen/patch_gen_common.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index c1290cfd5..be9433279 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -55,8 +55,10 @@ void GeneratePatch(const std::string& srcFileName,const std::string& destFileNam #ifdef NL_OS_WINDOWS _spawnlp(_P_WAIT, "xdelta.exe","xdelta.exe","delta",srcFileName.c_str(),destFileName.c_str(),patchFileName.c_str(),NULL); #else // NL_OS_WINDOWS + // xdelta-1.x behaves like "diff" and returns 0 for identical files, 1 for different files, 2 for errors sint error = system (cmd.c_str()); - if (error) + + if (error == 2) nlwarning("'%s' failed with error code %d", cmd.c_str(), error); #endif // NL_OS_WINDOWS } @@ -69,8 +71,10 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c #ifdef NL_OS_WINDOWS _spawnlp(_P_WAIT, "xdelta.exe","xdelta.exe","patch",patchFileName.c_str(),srcFileName.c_str(),destFileName.c_str(),NULL); #else // NL_OS_WINDOWS + // xdelta-1.x behaves like "diff" and returns 0 for identical files, 1 for different files, 2 for errors sint error = system (cmd.c_str()); - if (error) + + if (error == 2) nlwarning("'%s' failed with error code %d", cmd.c_str(), error); #endif // NL_OS_WINDOWS } From 50c86db753e614105c2413e459e663baf19a0623 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 14 Jun 2016 22:58:58 +0200 Subject: [PATCH 2/3] Changed: Minor changes --HG-- branch : develop --- code/ryzom/tools/patch_gen/patch_gen_common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index be9433279..27f5e9251 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -53,7 +53,7 @@ void GeneratePatch(const std::string& srcFileName,const std::string& destFileNam cmd+=" "+srcFileName+" "+destFileName+" "+patchFileName; nlinfo("executing system command: %s",cmd.c_str()); #ifdef NL_OS_WINDOWS - _spawnlp(_P_WAIT, "xdelta.exe","xdelta.exe","delta",srcFileName.c_str(),destFileName.c_str(),patchFileName.c_str(),NULL); + _spawnlp(_P_WAIT, "xdelta.exe", "xdelta.exe", "delta", srcFileName.c_str(), destFileName.c_str(), patchFileName.c_str(), NULL); #else // NL_OS_WINDOWS // xdelta-1.x behaves like "diff" and returns 0 for identical files, 1 for different files, 2 for errors sint error = system (cmd.c_str()); @@ -69,7 +69,7 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c cmd+=" "+patchFileName+" "+srcFileName+" "+destFileName; nlinfo("executing system command: %s",cmd.c_str()); #ifdef NL_OS_WINDOWS - _spawnlp(_P_WAIT, "xdelta.exe","xdelta.exe","patch",patchFileName.c_str(),srcFileName.c_str(),destFileName.c_str(),NULL); + _spawnlp(_P_WAIT, "xdelta.exe", "xdelta.exe", "patch",patchFileName.c_str(), srcFileName.c_str(), destFileName.c_str(), NULL); #else // NL_OS_WINDOWS // xdelta-1.x behaves like "diff" and returns 0 for identical files, 1 for different files, 2 for errors sint error = system (cmd.c_str()); From e3541dcc06bc55be159953e2c3478764821d72fe Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 14 Jun 2016 22:59:48 +0200 Subject: [PATCH 3/3] Changed: Use toString to format string --HG-- branch : develop --- code/ryzom/tools/patch_gen/patch_gen_common.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index 27f5e9251..8ba0d4c5e 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -49,9 +49,10 @@ void normalisePackageDescriptionFileName(std::string& fileName) void GeneratePatch(const std::string& srcFileName,const std::string& destFileName,const std::string& patchFileName) { - std::string cmd="xdelta delta"; - cmd+=" "+srcFileName+" "+destFileName+" "+patchFileName; - nlinfo("executing system command: %s",cmd.c_str()); + std::string cmd = toString("xdelta delta %s %s %s", srcFileName.c_str(), destFileName.c_str(), patchFileName.c_str()); + + nlinfo("Executing system command: %s", cmd.c_str()); + #ifdef NL_OS_WINDOWS _spawnlp(_P_WAIT, "xdelta.exe", "xdelta.exe", "delta", srcFileName.c_str(), destFileName.c_str(), patchFileName.c_str(), NULL); #else // NL_OS_WINDOWS @@ -65,9 +66,10 @@ void GeneratePatch(const std::string& srcFileName,const std::string& destFileNam void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,const std::string& patchFileName=std::string()) { - std::string cmd="xdelta patch"; - cmd+=" "+patchFileName+" "+srcFileName+" "+destFileName; - nlinfo("executing system command: %s",cmd.c_str()); + std::string cmd = toString("xdelta patch %s %s %s", patchFileName.c_str(), srcFileName.c_str(), destFileName.c_str()); + + nlinfo("Executing system command: %s", cmd.c_str()); + #ifdef NL_OS_WINDOWS _spawnlp(_P_WAIT, "xdelta.exe", "xdelta.exe", "patch",patchFileName.c_str(), srcFileName.c_str(), destFileName.c_str(), NULL); #else // NL_OS_WINDOWS