diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index c1290cfd5..8ba0d4c5e 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -49,28 +49,34 @@ 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); + _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 } 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); + _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 }