This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 3ea3f1b66fde1046f6e901660756e4b474524e26
Author: Mihai Moldovan <io...@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 fe4089b..38b4fa4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -305,6 +305,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 ().
 
  -- X2Go Release Manager <git-ad...@x2go.org>  Mon, 19 Sep 2016 09:07:07 +0200
 
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
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
http://lists.x2go.org/listinfo/x2go-commits

Reply via email to