mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
Ref T304, array index fix if "7za.exe" is not available
This commit is contained in:
@@ -83,11 +83,29 @@ namespace BlackMisc
|
||||
const bool win = CBuildConfig::isRunningOnWindowsNtPlatform();
|
||||
if (!win) { return CCompressUtils::whichZip7(stdOutAndError); }
|
||||
|
||||
// windows check
|
||||
QStringList args;
|
||||
args << "i";
|
||||
QProcess zipProcess;
|
||||
zipProcess.start("7za.exe", args);
|
||||
const bool finished = zipProcess.waitForFinished();
|
||||
if (stdOutAndError)
|
||||
{
|
||||
stdOutAndError->clear();
|
||||
const QString pStdout = zipProcess.readAllStandardOutput();
|
||||
const QString pStderr = zipProcess.readAllStandardError();
|
||||
if (pStdout.isEmpty() && pStderr.isEmpty())
|
||||
{
|
||||
stdOutAndError->push_back("Checking 7za");
|
||||
stdOutAndError->push_back("No 7za or failing");
|
||||
}
|
||||
else
|
||||
{
|
||||
stdOutAndError->push_back(pStdout);
|
||||
stdOutAndError->push_back(pStderr);
|
||||
}
|
||||
}
|
||||
|
||||
if (zipProcess.exitStatus() != QProcess::NormalExit) { return false; }
|
||||
if (!finished) { return false; }
|
||||
const int r = zipProcess.exitCode();
|
||||
|
||||
@@ -108,6 +108,14 @@ namespace BlackMisc
|
||||
return s.trimmed();
|
||||
}
|
||||
|
||||
//! Safe "at" function, returns empty string if index does not exists
|
||||
inline const QString &safeAt(const QStringList &stringList, int index)
|
||||
{
|
||||
if (stringList.size() > index) { return stringList.at(index); }
|
||||
static const QString empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
//! String with digits only
|
||||
inline bool isDigitsOnlyString(const QString &testString)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user