aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaUtils.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-10-08 14:21:05 -0400
committerKen Moore <ken@pcbsd.org>2014-10-08 14:21:05 -0400
commit2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d (patch)
tree07a6748fd0d2f6199fd799d0e579c42bfc6df9e7 /libLumina/LuminaUtils.cpp
parentClean up the default filemanager/terminal settings. Put them in the main sess... (diff)
downloadlumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.tar.gz
lumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.tar.bz2
lumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.zip
Add better binary detection to LuminaUtils, and setup lumina-open to use it.
Diffstat (limited to 'libLumina/LuminaUtils.cpp')
-rw-r--r--libLumina/LuminaUtils.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index 03b71cc9..46c2e26c 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -64,3 +64,17 @@ bool LUtils::writeFile(QString filepath, QStringList contents, bool overwrite){
}
return ok;
}
+
+bool LUtils::isValidBinary(QString bin){
+ if(!bin.startsWith("/")){
+ //Relative path: search for it on the current "PATH" settings
+ QStringList paths = QString(qgetenv("PATH")).split(":");
+ for(int i=0; i<paths.length(); i++){
+ if(QFile::exists(paths[i]+"/"+bin)){ bin = paths[i]+"/"+bin; break;}
+ }
+ }
+ //bin should be the full path by now
+ if(!bin.startsWith("/")){ return false; }
+ QFileInfo info(bin);
+ return (info.exists() && info.isExecutable());
+}
bgstack15