diff options
author | Shawn Pearce <spearce@spearce.org> | 2010-09-01 17:59:54 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2010-09-01 17:59:55 -0400 |
commit | c7e1199b56db17058bb055e4e140e1991838c46b (patch) | |
tree | 98e54cfea8bd1e1fded7238fde41ae9eaf8c33c7 /org.eclipse.jgit | |
parent | 1ea356b3465974a955c0118725c9bafce657a0e6 (diff) | |
parent | a46abab244cec1dfc52af861744e1e93efd8d314 (diff) | |
download | jgit-c7e1199b56db17058bb055e4e140e1991838c46b.tar.gz jgit-c7e1199b56db17058bb055e4e140e1991838c46b.zip |
Merge "Add FS.detect() for detection of file system abstraction."
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 40 |
1 files changed, 34 insertions, 6 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 cb5c8bda54..9e817ca770 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -52,16 +52,44 @@ public abstract class FS { /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED; - static { + /** + * Auto-detect the appropriate file system abstraction, taking into account + * the presence of a Cygwin installation on the system. Using jgit in + * combination with Cygwin requires a more elaborate (and possibly slower) + * resolution of file system paths. + * + * @param cygwinUsed + * <ul> + * <li><code>Boolean.TRUE</code> to assume that Cygwin is used in + * combination with jgit</li> + * <li><code>Boolean.FALSE</code> to assume that Cygwin is + * <b>not</b> used with jgit</li> + * <li><code>null</code> to auto-detect whether a Cygwin + * installation is present on the system and in this case assume + * that Cygwin is used</li> + * </ul> + * + * Note: this parameter is only relevant on Windows. + * + * @return detected file system abstraction + */ + public static FS detect(Boolean cygwinUsed) { if (FS_Win32.detect()) { - if (FS_Win32_Cygwin.detect()) - DETECTED = new FS_Win32_Cygwin(); + boolean useCygwin = (cygwinUsed == null && FS_Win32_Cygwin.detect()) + || Boolean.TRUE.equals(cygwinUsed); + + if (useCygwin) + return new FS_Win32_Cygwin(); else - DETECTED = new FS_Win32(); + return new FS_Win32(); } else if (FS_POSIX_Java6.detect()) - DETECTED = new FS_POSIX_Java6(); + return new FS_POSIX_Java6(); else - DETECTED = new FS_POSIX_Java5(); + return new FS_POSIX_Java5(); + } + + static { + DETECTED = detect(null); } private final File userHome; |