Browse Source

Refactor detection of Windows platform to SystemReader

Change-Id: Id0b8aef92f10572d4f1ec198e0281162fcd7ed4e
stable-2.1
Robin Rosenberg 12 years ago
parent
commit
9570e0d4a9
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
  4. 14
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
  5. 13
      org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

3
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -1022,8 +1022,7 @@ public class DirCacheCheckout {
}
private static boolean isValidPathSegment(CanonicalTreeParser t) {
String osName = SystemReader.getInstance().getProperty("os.name");
boolean isWindows = "Windows".equals(osName);
boolean isWindows = SystemReader.getInstance().isWindows();
boolean isOSX = SystemReader.getInstance().isMacOS();
boolean ignCase = isOSX || isWindows;

3
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java vendored

@ -724,8 +724,7 @@ public class DirCacheEntry {
case ':':
// Tree's never have a backslash in them, not even on Windows
// but even there we regard it as an invalid path
if ("Windows".equals(SystemReader.getInstance().getProperty(
"os.name")))
if (SystemReader.getInstance().isWindows())
return false;
//$FALL-THROUGH$
default:

2
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

@ -89,7 +89,7 @@ public abstract class FS {
* @return detected file system abstraction
*/
public static FS detect(Boolean cygwinUsed) {
if (FS_Win32.isWin32()) {
if (SystemReader.getInstance().isWindows()) {
if (cygwinUsed == null)
cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin());
if (cygwinUsed.booleanValue())

14
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java

@ -46,25 +46,11 @@ package org.eclipse.jgit.util;
import java.io.File;
import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class FS_Win32 extends FS {
static boolean isWin32() {
final String osDotName = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty("os.name");
}
});
return osDotName != null
&& StringUtils.toLowerCase(osDotName).indexOf("windows") != -1;
}
FS_Win32() {
super();
}

13
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

@ -239,6 +239,19 @@ public abstract class SystemReader {
return DateFormat.getDateTimeInstance(dateStyle, timeStyle);
}
/**
* @return true if we are running on a Windows.
*/
public boolean isWindows() {
String osDotName = AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return getProperty("os.name");
}
});
return osDotName.startsWith("Windows");
}
/**
* @return true if we are running on Mac OS X
*/

Loading…
Cancel
Save