commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [2/2] commons-io git commit: Sort members.
Date Sat, 18 Nov 2017 20:32:23 GMT
Sort members.

Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/30280a9b
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/30280a9b
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/30280a9b

Branch: refs/heads/master
Commit: 30280a9ba706b330cbf6b18e6f2f6660743c0f16
Parents: 38b0ff1
Author: Gary Gregory <ggregory@apache.org>
Authored: Sat Nov 18 13:32:19 2017 -0700
Committer: Gary Gregory <ggregory@apache.org>
Committed: Sat Nov 18 13:32:19 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/commons/io/FileSystem.java  | 92 ++++++++++----------
 1 file changed, 46 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/30280a9b/src/main/java/org/apache/commons/io/FileSystem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/FileSystem.java b/src/main/java/org/apache/commons/io/FileSystem.java
index 38b2e58..ffc0d98 100644
--- a/src/main/java/org/apache/commons/io/FileSystem.java
+++ b/src/main/java/org/apache/commons/io/FileSystem.java
@@ -32,6 +32,8 @@ import java.util.Objects;
  */
 public enum FileSystem {
 
+    GENERIC(Integer.MAX_VALUE, Integer.MAX_VALUE, new char[] { 0 }, new String[] {}),
+
     LINUX(255, 4096, new char[] {
             // KEEP THIS ARRAY SORTED!
             // @formatter:off
@@ -51,8 +53,6 @@ public enum FileSystem {
             // @formatter:on
     }, new String[] {}),
 
-    GENERIC(Integer.MAX_VALUE, Integer.MAX_VALUE, new char[] { 0 }, new String[] {}),
-
     WINDOWS(255, 32000, new char[] {
             // KEEP THIS ARRAY SORTED!
             // @formatter:off
@@ -69,39 +69,39 @@ public enum FileSystem {
                     "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "NUL",
"PRN" });
 
     /**
-     * The prefix String for all Windows OS.
-     */
-    private static final String OS_NAME_WINDOWS_PREFIX = "Windows";
-
-    /**
      * <p>
-     * Is {@code true} if this is Windows.
+     * Is {@code true} if this is Linux.
      * </p>
      * <p>
      * The field will return {@code false} if {@code OS_NAME} is {@code null}.
      * </p>
      */
-    private static final boolean IS_OS_WINDOWS = getOsMatchesName(OS_NAME_WINDOWS_PREFIX);
+    private static final boolean IS_OS_LINUX = getOsMatchesName("Linux") || getOsMatchesName("LINUX");
 
     /**
      * <p>
-     * Is {@code true} if this is Linux.
+     * Is {@code true} if this is Mac.
      * </p>
      * <p>
      * The field will return {@code false} if {@code OS_NAME} is {@code null}.
      * </p>
      */
-    private static final boolean IS_OS_LINUX = getOsMatchesName("Linux") || getOsMatchesName("LINUX");
+    private static final boolean IS_OS_MAC = getOsMatchesName("Mac");
+
+    /**
+     * The prefix String for all Windows OS.
+     */
+    private static final String OS_NAME_WINDOWS_PREFIX = "Windows";
 
     /**
      * <p>
-     * Is {@code true} if this is Mac.
+     * Is {@code true} if this is Windows.
      * </p>
      * <p>
      * The field will return {@code false} if {@code OS_NAME} is {@code null}.
      * </p>
      */
-    private static final boolean IS_OS_MAC = getOsMatchesName("Mac");
+    private static final boolean IS_OS_WINDOWS = getOsMatchesName(OS_NAME_WINDOWS_PREFIX);
 
     private static final String OS_NAME = getSystemProperty("os.name");
 
@@ -231,6 +231,15 @@ public enum FileSystem {
     }
 
     /**
+     * Gets the reserved file names.
+     * 
+     * @return the reserved file names.
+     */
+    public String[] getReservedFileNames() {
+        return reservedFileNames;
+    }
+
+    /**
      * Returns {@code true} if the given character is illegal in a file name, {@code false}
otherwise.
      * 
      * @param c
@@ -242,6 +251,30 @@ public enum FileSystem {
     }
 
     /**
+     * Checks if a candidate file name (without a path) such as {@code "filename.ext"} or
{@code "filename"} is a
+     * potentially legal file name. If the file name length exceeds {@link #getMaxFileNameLength()},
or if it contains
+     * an illegal character then the check fails.
+     *
+     * @param candidate
+     *            a candidate file name (without a path) like {@code "filename.ext"} or {@code
"filename"}
+     * @return {@code true} if the candidate name is legal
+     */
+    public boolean isLegalFileName(final CharSequence candidate) {
+        if (candidate == null || candidate.length() == 0 || candidate.length() > maxFileNameLength)
{
+            return false;
+        }
+        if (isReservedFileName(candidate)) {
+            return false;
+        }
+        for (int i = 0; i < candidate.length(); i++) {
+            if (isIllegalFileNameChar(candidate.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
      * Returns whether the given string is a reserved file name.
      * 
      * @param candidate
@@ -283,37 +316,4 @@ public enum FileSystem {
         }
         return changed ? String.valueOf(charArray) : truncated;
     }
-
-    /**
-     * Checks if a candidate file name (without a path) such as {@code "filename.ext"} or
{@code "filename"} is a
-     * potentially legal file name. If the file name length exceeds {@link #getMaxFileNameLength()},
or if it contains
-     * an illegal character then the check fails.
-     *
-     * @param candidate
-     *            a candidate file name (without a path) like {@code "filename.ext"} or {@code
"filename"}
-     * @return {@code true} if the candidate name is legal
-     */
-    public boolean isLegalFileName(final CharSequence candidate) {
-        if (candidate == null || candidate.length() == 0 || candidate.length() > maxFileNameLength)
{
-            return false;
-        }
-        if (isReservedFileName(candidate)) {
-            return false;
-        }
-        for (int i = 0; i < candidate.length(); i++) {
-            if (isIllegalFileNameChar(candidate.charAt(i))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Gets the reserved file names.
-     * 
-     * @return the reserved file names.
-     */
-    public String[] getReservedFileNames() {
-        return reservedFileNames;
-    }
 }
\ No newline at end of file


Mime
View raw message