Skip to content

Commit

Permalink
improved detection of p7zip/ffprobe
Browse files Browse the repository at this point in the history
  • Loading branch information
krzemin committed Nov 22, 2015
1 parent 8982df3 commit 6f725ef
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/qnapiconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ QString QNapiConfig::p7zipPath()
if(!p7z_path.isEmpty() && QFileInfo(p7z_path).isExecutable())
return p7z_path;

#ifdef Q_OS_WIN
QString separator = ";";
#else
QString separator = ":";
#endif

// Przeszukiwanie sciezek systemowych i biezacego katalogu
QString path = QProcess::systemEnvironment().filter(QRegExp("^PATH=(.*)$")).value(0);
QStringList paths = path.mid(5).split(":");
QStringList paths = path.mid(5).split(separator);
paths.removeAll("");
paths.append(".");

if(paths.size() == 0)
paths << "/usr/bin" << "/usr/local/bin";
paths << "/bin" << "/usr/bin" << "/usr/local/bin";

#ifdef Q_OS_MAC
// Pod MacOS X 7zip jest w zasobach aplikacji
Expand All @@ -87,14 +93,13 @@ QString QNapiConfig::p7zipPath()
{
p7z_path = (*i) + "/" + (*j);
if(QFileInfo(p7z_path).isExecutable())
return p7z_path;
return QFileInfo(p7z_path).absoluteFilePath();
}
}


#ifdef Q_OS_WIN
// Pod systemem Windows program 7za.exe musi byc w tym samym katalogu,
// co qnapi.exe
// Pod systemem Windows program 7za.exe musi byc w tym samym katalogu, co qnapi.exe
p7z_path = QFileInfo(QApplication::applicationDirPath() + "/7za.exe").absoluteFilePath();
if(QFileInfo(p7z_path).isExecutable())
return p7z_path;
Expand All @@ -111,17 +116,23 @@ QString QNapiConfig::ffProbePath()
if(!ffprobe_path.isEmpty() && QFileInfo(ffprobe_path).isExecutable())
return ffprobe_path;

#ifdef Q_OS_WIN
QString separator = ";";
#else
QString separator = ":";
#endif

// Przeszukiwanie sciezek systemowych i biezacego katalogu
QString path = QProcess::systemEnvironment().filter(QRegExp("^PATH=(.*)$")).value(0);
QStringList paths = path.mid(5).split(":");
QStringList paths = path.mid(5).split(separator);
paths.removeAll("");
paths.append(".");

if(paths.size() == 0)
paths << "/usr/bin" << "/usr/local/bin";
paths << "/bin" << "/usr/bin" << "/usr/local/bin";

#ifdef Q_OS_MAC
// Pod MacOS X 7zip jest w zasobach aplikacji
// Pod MacOS X ffprobe jest w zasobach aplikacji
paths << QDir(QApplication::applicationDirPath() + "/../Resources").canonicalPath();
#endif

Expand All @@ -130,13 +141,12 @@ QString QNapiConfig::ffProbePath()
{
ffprobe_path = (*i) + "/" + binary;
if(QFileInfo(ffprobe_path).isExecutable())
return ffprobe_path;
return QFileInfo(ffprobe_path).absoluteFilePath();
}


#ifdef Q_OS_WIN
// Pod systemem Windows program ffprobe.exe musi byc w tym samym katalogu,
// co qnapi.exe
// Pod systemem Windows program ffprobe.exe musi byc w tym samym katalogu, co qnapi.exe
ffprobe_path = QFileInfo(QApplication::applicationDirPath() + "/ffprobe.exe").absoluteFilePath();
if(QFileInfo(ffprobe_path).isExecutable())
return ffprobe_path;
Expand Down

0 comments on commit 6f725ef

Please sign in to comment.