mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Implement 7zip uncompressing on Mac OS
This commit is contained in:
committed by
Klaus Basan
parent
6d6d06030d
commit
15de5ec41d
Submodule externals updated: f5c075c6c9...5ad2689fbf
@@ -44,51 +44,62 @@ namespace BlackMisc
|
|||||||
const QString f = win ? CFileUtils::toWindowsLocalPath(file) : file;
|
const QString f = win ? CFileUtils::toWindowsLocalPath(file) : file;
|
||||||
|
|
||||||
// 7za.exe x -o"P:\Temp\XPlane" c:\Users\Foo\Downloads\xswiftbus-allos-0.8.4.802111947.7z
|
// 7za.exe x -o"P:\Temp\XPlane" c:\Users\Foo\Downloads\xswiftbus-allos-0.8.4.802111947.7z
|
||||||
const QString cmd = win ? QStringLiteral("7za.exe") : QStringLiteral("7za");
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "x";
|
args << "x";
|
||||||
args << "-aoa";
|
args << "-aoa";
|
||||||
if (!d.isEmpty()) { args << "-o" + d; }
|
if (!d.isEmpty()) { args << "-o" + d; }
|
||||||
args << f;
|
args << f;
|
||||||
|
|
||||||
|
QProcess *zipProcess = new QProcess();
|
||||||
|
zipProcess->setWorkingDirectory(CDirectoryUtils::binDirectory());
|
||||||
|
zipProcess->setProgram(QStringLiteral("7za"));
|
||||||
|
zipProcess->setArguments(args);
|
||||||
|
|
||||||
if (wait)
|
if (wait)
|
||||||
{
|
{
|
||||||
QProcess zipProcess;
|
|
||||||
zipProcess.start(cmd, args);
|
zipProcess->start();
|
||||||
const bool finished = zipProcess.waitForFinished();
|
const bool finished = zipProcess->waitForFinished();
|
||||||
if (zipProcess.exitStatus() != QProcess::NormalExit) { return false; }
|
if (zipProcess->exitStatus() != QProcess::NormalExit) { return false; }
|
||||||
if (!finished) { return false; }
|
if (!finished) { return false; }
|
||||||
const int r = zipProcess.exitCode();
|
const int r = zipProcess->exitCode();
|
||||||
if (stdOutAndError)
|
if (stdOutAndError)
|
||||||
{
|
{
|
||||||
const QString pStdout = zipProcess.readAllStandardOutput();
|
const QString pStdout = zipProcess->readAllStandardOutput();
|
||||||
const QString pStderr = zipProcess.readAllStandardError();
|
const QString pStderr = zipProcess->readAllStandardError();
|
||||||
stdOutAndError->clear();
|
stdOutAndError->clear();
|
||||||
stdOutAndError->push_back(pStdout);
|
stdOutAndError->push_back(pStdout);
|
||||||
stdOutAndError->push_back(pStderr);
|
stdOutAndError->push_back(pStderr);
|
||||||
}
|
}
|
||||||
|
zipProcess->deleteLater();
|
||||||
return r == 0;
|
return r == 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QProcess *p = new QProcess();
|
// FIXME: zipProcess is leaked here.
|
||||||
p->start(cmd, args);
|
zipProcess->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCompressUtils::hasZip7(QStringList *stdOutAndError)
|
bool CCompressUtils::hasZip7(QStringList *stdOutAndError)
|
||||||
{
|
{
|
||||||
// just display info
|
// just display info
|
||||||
const bool win = CBuildConfig::isRunningOnWindowsNtPlatform();
|
const bool isLinux = CBuildConfig::isRunningOnLinuxPlatform();
|
||||||
if (!win) { return CCompressUtils::whichZip7(stdOutAndError); }
|
if (isLinux) { return CCompressUtils::whichZip7(stdOutAndError); }
|
||||||
|
|
||||||
// windows check
|
// windows check
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "i";
|
args << "i";
|
||||||
QProcess zipProcess;
|
QProcess zipProcess;
|
||||||
zipProcess.start("7za.exe", args);
|
zipProcess.setWorkingDirectory(CDirectoryUtils::binDirectory());
|
||||||
|
zipProcess.setProgram(QStringLiteral("7za"));
|
||||||
|
zipProcess.setArguments(args);
|
||||||
|
zipProcess.start();
|
||||||
const bool finished = zipProcess.waitForFinished();
|
const bool finished = zipProcess.waitForFinished();
|
||||||
|
|
||||||
if (stdOutAndError)
|
if (stdOutAndError)
|
||||||
{
|
{
|
||||||
stdOutAndError->clear();
|
stdOutAndError->clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user