You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2018/02/04 10:46:49 UTC

commons-io git commit: IO-567: Implement special case handling for NTFS ADS names

Repository: commons-io
Updated Branches:
  refs/heads/master cfb682e9d -> 27fb1044f


IO-567:  Implement special case handling for NTFS ADS names

fix checkstyle violation by replacing tabs with spaces


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

Branch: refs/heads/master
Commit: 27fb1044f1f244a9f8841f059392bd7e595797a3
Parents: cfb682e
Author: pascalschumacher <pa...@gmx.net>
Authored: Sun Feb 4 11:46:43 2018 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sun Feb 4 11:46:43 2018 +0100

----------------------------------------------------------------------
 .../org/apache/commons/io/FilenameUtils.java    | 44 ++++++++++----------
 1 file changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/27fb1044/src/main/java/org/apache/commons/io/FilenameUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java b/src/main/java/org/apache/commons/io/FilenameUtils.java
index 71bd4d4..fec3603 100644
--- a/src/main/java/org/apache/commons/io/FilenameUtils.java
+++ b/src/main/java/org/apache/commons/io/FilenameUtils.java
@@ -734,11 +734,11 @@ public class FilenameUtils {
             return NOT_FOUND;
         }
         if (isSystemWindows()) {
-        	// Special handling for NTFS ADS: Don't accept colon in the filename.
-        	final int offset = filename.indexOf(':', getAdsCriticalOffset(filename));
-        	if (offset != -1) {
-        		throw new IllegalArgumentException("NTFS ADS separator (':') in filename is forbidden.");
-        	}
+            // Special handling for NTFS ADS: Don't accept colon in the filename.
+            final int offset = filename.indexOf(':', getAdsCriticalOffset(filename));
+            if (offset != -1) {
+                throw new IllegalArgumentException("NTFS ADS separator (':') in filename is forbidden.");
+            }
         }
         final int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR);
         final int lastSeparator = indexOfLastSeparator(filename);
@@ -1070,24 +1070,24 @@ public class FilenameUtils {
     }
 
     private static int getAdsCriticalOffset(String filename) {
-    	// Step 1: Remove leading path segments.
-    	int offset1 = filename.lastIndexOf(SYSTEM_SEPARATOR);
-    	int offset2 = filename.lastIndexOf(OTHER_SEPARATOR);
-    	if (offset1 == -1) {
-    		if (offset2 == -1) {
-    			return 0;
-    		} else {
-    			return offset2 + 1;
-    		}
-    	} else {
-    		if (offset2 == -1) {
-    			return offset1+1;
-    		} else {
-    			return Math.max(offset1, offset2)+1;
-    		}
-    	}
+        // Step 1: Remove leading path segments.
+        int offset1 = filename.lastIndexOf(SYSTEM_SEPARATOR);
+        int offset2 = filename.lastIndexOf(OTHER_SEPARATOR);
+        if (offset1 == -1) {
+            if (offset2 == -1) {
+                return 0;
+            } else {
+                return offset2 + 1;
+            }
+        } else {
+            if (offset2 == -1) {
+                return offset1 + 1;
+            } else {
+                return Math.max(offset1, offset2) + 1;
+            }
+        }
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Removes the extension from a filename.