Mercurial > hg > easyhg
comparison common.cpp @ 214:478d0222e93d
* Further findInPath fix for absolute paths
author | Chris Cannam |
---|---|
date | Wed, 05 Jan 2011 16:20:20 +0000 |
parents | 90e70a9024f3 |
children | 8fd71f570884 |
comparison
equal
deleted
inserted
replaced
213:90e70a9024f3 | 214:478d0222e93d |
---|---|
57 QChar pathSep = ':'; | 57 QChar pathSep = ':'; |
58 #endif | 58 #endif |
59 name = QFileInfo(name).fileName(); | 59 name = QFileInfo(name).fileName(); |
60 QString path = | 60 QString path = |
61 QProcessEnvironment::systemEnvironment().value("PATH"); | 61 QProcessEnvironment::systemEnvironment().value("PATH"); |
62 DEBUG << "findExecutable: seeking location for binary " << name | 62 DEBUG << "findInPath: seeking location for binary " << name |
63 << ": system path is " << path << endl; | 63 << ": system path is " << path << endl; |
64 if (installPath != "") { | 64 if (installPath != "") { |
65 DEBUG << "findExecutable: install path is " << installPath | 65 DEBUG << "findInPath: install path is " << installPath |
66 << ", adding to system path" << endl; | 66 << ", adding to system path" << endl; |
67 //!!! path = path + pathSep + installPath; | 67 //!!! path = path + pathSep + installPath; |
68 path = installPath + pathSep + path; | 68 path = installPath + pathSep + path; |
69 } | 69 } |
70 #ifndef Q_OS_WIN32 | 70 #ifndef Q_OS_WIN32 |
75 #endif | 75 #endif |
76 QStringList elements = path.split(pathSep, QString::SkipEmptyParts); | 76 QStringList elements = path.split(pathSep, QString::SkipEmptyParts); |
77 foreach (QString element, elements) { | 77 foreach (QString element, elements) { |
78 QString full = QDir(element).filePath(name); | 78 QString full = QDir(element).filePath(name); |
79 QFileInfo fi(full); | 79 QFileInfo fi(full); |
80 DEBUG << "findExecutable: looking at " << full << endl; | 80 DEBUG << "findInPath: looking at " << full << endl; |
81 if (fi.exists() && fi.isFile()) { | 81 if (fi.exists() && fi.isFile()) { |
82 DEBUG << "findExecutable: it's a file" << endl; | 82 DEBUG << "findInPath: it's a file" << endl; |
83 if (!executableRequired || fi.isExecutable()) { | 83 if (!executableRequired || fi.isExecutable()) { |
84 name = full; | 84 name = full; |
85 DEBUG << "findExecutable: found at " << name << endl; | 85 DEBUG << "findInPath: found at " << name << endl; |
86 found = true; | 86 found = true; |
87 break; | 87 break; |
88 } | 88 } |
89 } | |
90 } | |
91 } else { | |
92 // absolute path given | |
93 QFileInfo fi(name); | |
94 DEBUG << "findInPath: looking at absolute path " << name << endl; | |
95 if (fi.exists() && fi.isFile()) { | |
96 DEBUG << "findInPath: it's a file" << endl; | |
97 if (!executableRequired || fi.isExecutable()) { | |
98 DEBUG << "findInPath: found at " << name << endl; | |
99 found = true; | |
89 } | 100 } |
90 } | 101 } |
91 } | 102 } |
92 } | 103 } |
93 #ifdef Q_OS_WIN32 | 104 #ifdef Q_OS_WIN32 |