diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-12-28 17:15:08 +0100 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-12-30 12:38:18 -0800 |
commit | 14b358a6fbe2aa9f04a1bb6a27812458af6a755e (patch) | |
tree | be53cadf74ffddabdf5a818d717261c9168b642c /org.eclipse.jgit | |
parent | 558879d820ee4d4154de34f21d4ddbf2f2a9bf32 (diff) | |
download | jgit-14b358a6fbe2aa9f04a1bb6a27812458af6a755e.tar.gz jgit-14b358a6fbe2aa9f04a1bb6a27812458af6a755e.zip |
Refactor search for a file within a PATH
Change-Id: I785ab6bf1823d174394b1d2b25c5bb202535e943
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 11 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java | 12 |
2 files changed, 15 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 9e817ca770..2287f68fa2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -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; + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java index 39f2c03a06..0af955f945 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java @@ -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) { |