mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-29 03:40:55 +00:00
Fixed: New LZMA syntax under Linux
This commit is contained in:
parent
fd3e147574
commit
0bfc783142
1 changed files with 23 additions and 4 deletions
|
@ -76,15 +76,34 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c
|
|||
|
||||
void GenerateLZMA(const std::string sourceFile, const std::string &outputFile)
|
||||
{
|
||||
std::string cmd="lzma e ";
|
||||
cmd+=" "+sourceFile+" "+outputFile;
|
||||
nlinfo("executing system command: %s",cmd.c_str());
|
||||
{
|
||||
// old syntax incompatible with new versions
|
||||
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
|
||||
sint error = system (cmd.c_str());
|
||||
// new lzma only supports one file name on command line, so make a copy
|
||||
CFile::copyFile(sourceFile, outputFile);
|
||||
|
||||
// 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)
|
||||
{
|
||||
nlwarning("'%s' failed with error code %d", cmd.c_str(), error);
|
||||
|
||||
CFile::deleteFile(outputFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
// lzma always append a .lzma extension, so rename compressed file to wanted one
|
||||
CFile::moveFile(outputFile + ".lzma", outputFile);
|
||||
}
|
||||
#endif // NL_OS_WINDOWS
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue