[X2Go-Commits] [x2goclient] 180/217: src/x2goutils.{cpp, h}: add new function find_binary ().

2016-09-20 Thread git-admin
This is an automated email from the git hooks/post-receive script.

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

commit ace31cc6efdfc194e6004f5aeae4c0b3c6cd287c
Author: Mihai Moldovan 
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 cffb0f2..8e76e61 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -301,6 +301,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   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 
 #include 
 #include 
+#include 
 
 #include "x2goutils.h"
 #include "onmainwindow.h"
@@ -282,4 +283,40 @@ QString add_to_path (const QString _path, const 
QStringList , const boo
 
   return (ret);
 }
+
+QString find_binary (const QString , const QString _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 _error, 
const QString 
  * Ex.: ::...:
  */
 QString add_to_path (const QString _path, const QStringList , 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 , const QString _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


[X2Go-Commits] [x2goclient] 180/217: src/x2goutils.{cpp, h}: add new function find_binary ().

2016-08-27 Thread git-admin
This is an automated email from the git hooks/post-receive script.

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

commit 7316e7c065f4bd5ca864c84cb1842d960dad7f92
Author: Mihai Moldovan 
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 ad4b865..1f73293 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -334,6 +334,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 .
 - Uploaders: add myself. Also, force a rebuild due to the changed
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 
 #include 
 #include 
+#include 
 
 #include "x2goutils.h"
 #include "onmainwindow.h"
@@ -282,4 +283,40 @@ QString add_to_path (const QString _path, const 
QStringList , const boo
 
   return (ret);
 }
+
+QString find_binary (const QString , const QString _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 _error, 
const QString 
  * Ex.: ::...:
  */
 QString add_to_path (const QString _path, const QStringList , 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 , const QString _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