Refactor search for a file within a PATH
Change-Id: I785ab6bf1823d174394b1d2b25c5bb202535e943
This commit is contained in:
parent
558879d820
commit
14b358a6fb
|
@ -199,4 +199,15 @@ public String run() {
|
|||
return null;
|
||||
return new File(home).getAbsoluteFile();
|
||||
}
|
||||
|
||||
static File searchPath(final String path, final String... lookFor) {
|
||||
for (final String p : path.split(File.pathSeparator)) {
|
||||
for (String command : lookFor) {
|
||||
final File e = new File(p, command);
|
||||
if (e.isFile())
|
||||
return e.getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,14 +62,10 @@ public String run() {
|
|||
});
|
||||
if (path == null)
|
||||
return false;
|
||||
for (final String p : path.split(";")) {
|
||||
final File e = new File(p, "cygpath.exe");
|
||||
if (e.isFile()) {
|
||||
cygpath = e.getAbsolutePath();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
File found = FS.searchPath(path, "cygpath.exe");
|
||||
if (found != null)
|
||||
cygpath = found.getPath();
|
||||
return cygpath != null;
|
||||
}
|
||||
|
||||
public File resolve(final File dir, final String pn) {
|
||||
|
|
Loading…
Reference in New Issue