[X2Go-Commits] [x2goclient] 180/276: src/x2goutils.{cpp, h}: add new function find_binary ().
git-admin at x2go.org
git-admin at x2go.org
Sat Dec 31 01:35:14 CET 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 7c99f21e1061fd4daef34689bea1fc3448690f19
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 59a6267..9971f32 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -311,6 +311,9 @@ x2goclient (4.0.5.3-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 ().
[ Bernard Cafarelli ]
* New upstream version (4.0.5.3):
diff --git a/src/x2goutils.cpp b/src/x2goutils.cpp
index 9f3b382..f6978c5 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"
@@ -287,4 +288,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