Browse Source

Refactor search for a file within a PATH

Change-Id: I785ab6bf1823d174394b1d2b25c5bb202535e943
tags/v0.11.1
Robin Rosenberg 13 years ago
parent
commit
14b358a6fb

+ 11
- 0
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java View File

@@ -199,4 +199,15 @@ public abstract class FS {
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;
}
}

+ 4
- 8
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java View File

@@ -62,14 +62,10 @@ class FS_Win32_Cygwin extends FS_Win32 {
});
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…
Cancel
Save