]> source.dussan.org Git - jgit.git/commitdiff
Refactor detection of Windows platform to SystemReader 17/7117/3
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 2 Aug 2012 23:33:34 +0000 (01:33 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 21 Aug 2012 22:37:17 +0000 (00:37 +0200)
Change-Id: Id0b8aef92f10572d4f1ec198e0281162fcd7ed4e

org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

index 1d8c0d01b632d8de31d77605b7cdb6861e7eeaf5..d43fef84772a2a4ee8bfd41c20f06e44ad8dbb10 100644 (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;
 
index aec12e316929264669c99674916bc9e08b0008ef..00af0657d0238d3532dccfc3459de31e85b3ee17 100644 (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:
index 535d1cd26a003f18aa0929a5eb76355c4dac6ae1..6eb020e52b11f06ae546b4e77e119682a2f6ac71 100644 (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())
index 3b6704497cfd7cd45d4940c670a390fe005d2d90..eebaa65d08c39ccf067065b30f2eed82b6a3e215 100644 (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();
        }
index 4298fbcf748570304aabe2d735aef92639af445e..7cddccc292c07a85280334113e375c4e6cc884a5 100644 (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
         */