Browse Source

Merge "Refactor detection of Windows platform to SystemReader"

tags/v2.1.0.201209190230-r
Matthias Sohn 11 years ago
parent
commit
0e684bb97c

+ 1
- 2
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java View File

@@ -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;


+ 1
- 2
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java View File

@@ -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:

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

@@ -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())

+ 0
- 14
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java View File

@@ -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
- 0
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java View File

@@ -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