[X2Go-Commits] [x2goclient] 01/01: src/x2goutils.{cpp, h}: add new function find_binary ().
git-admin at x2go.org
git-admin at x2go.org
Mon Jun 20 23:56:40 CEST 2016
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/osx
in repository x2goclient.
commit 3d491d9e7561cd31a0269df905d350efaeef28df
Author: Mihai Moldovan <ionic at ionic.de>
Date: Mon Jun 20 23:52:40 2016 +0200
src/x2goutils.{cpp,h}: add new function find_binary ().
Searches for a specific binary in a colon-separated list of paths.
Really just a compat function, as Qt 5 includes
QStandardPaths::findExecutable ().
---
debian/changelog | 3 +++
src/x2goutils.cpp | 37 +++++++++++++++++++++++++++++++++++++
src/x2goutils.h | 8 ++++++++
3 files changed, 48 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index f7dec11..2c16f08 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -330,6 +330,9 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
start binaries like paplay.
- src/pulsemanager.cpp: don't remove PA config and log file in
~/.x2go/pulse on PA shutdown if debugging has been requested.
+ - src/x2goutils.{cpp,h}: add new function find_binary (). Searches for a
+ specific binary in a colon-separated list of paths. Really just a compat
+ function, as Qt 5 includes QStandardPaths::findExecutable ().
* debian/control:
- Maintainer change in package: X2Go Developers <x2go-dev at lists.x2go.org>.
diff --git a/src/x2goutils.cpp b/src/x2goutils.cpp
index 31ac3ac..16ed06e 100644
--- a/src/x2goutils.cpp
+++ b/src/x2goutils.cpp
@@ -24,6 +24,7 @@
#include <QFont>
#include <QFontInfo>
#include <QObject>
+#include <QStringList>
#include "x2goutils.h"
#include "onmainwindow.h"
@@ -282,4 +283,40 @@ QString add_to_path (const QString &orig_path, const QStringList &add, const boo
return (ret);
}
+
+QString find_binary (const QString &path, const QString &binary_name) {
+ QString ret = "";
+
+ if (!(binary_name.isEmpty ())) {
+ QString cur_path = "";
+ QString tmp_path = path;
+
+ if (!(path.isEmpty ())) {
+ tmp_path = "./";
+ }
+
+ QStringList path_list = tmp_path.split (":");
+
+ for (QStringList const_it = path_list.constBegin (); const_it != path_list.constEnd (); ++const_it) {
+ cur_path = *const_it;
+
+ if (cur_path.isEmpty ()) {
+ cur_path = "./";
+ }
+
+ cur_path = QDir (cur_path).absolutePath ();
+
+ cur_path += "/" + binary_name;
+
+ QFileInfo tmp_file_info = QFileInfo (cur_path);
+
+ if ((tmp_file_info.exists ()) && (tmp_file_info.isExecutable ())) {
+ ret = tmp_file_info.canonicalFilePath ();
+ break;
+ }
+ }
+ }
+
+ return (ret);
+}
#endif /* defined (Q_OS_DARWIN) */
diff --git a/src/x2goutils.h b/src/x2goutils.h
index e36203e..4159d39 100644
--- a/src/x2goutils.h
+++ b/src/x2goutils.h
@@ -57,6 +57,14 @@ void show_XQuartz_generic_error (const QString &main_error, const QString &addit
* Ex.: <add_entry1>:<add_entry2>:...:<orig_path>
*/
QString add_to_path (const QString &orig_path, const QStringList &add, const bool back = true);
+
+/*
+ * Returns the first existing path that contains binary_name.
+ * Iff no component contains a binary called binary_name, an empty path is returned.
+ *
+ * Iff path is empty, (only) the current working dir is searched.
+ */
+QString find_binary (const QString &path, const QString &binary_name);
#endif /* defined (Q_OS_DARWIN) */
#endif /* !defined (X2GOUTILS_H) */
--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list