[jboss-cvs] JBossAS SVN: r101796 - projects/vfs/trunk/src/main/java/org/jboss/vfs.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 3 19:32:35 EST 2010


Author: jason.greene at jboss.com
Date: 2010-03-03 19:32:34 -0500 (Wed, 03 Mar 2010)
New Revision: 101796

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/vfs/VFS.java
Log:
Extra pedantic sanity checking

Modified: projects/vfs/trunk/src/main/java/org/jboss/vfs/VFS.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/vfs/VFS.java	2010-03-04 00:21:53 UTC (rev 101795)
+++ projects/vfs/trunk/src/main/java/org/jboss/vfs/VFS.java	2010-03-04 00:32:34 UTC (rev 101796)
@@ -217,26 +217,27 @@
             //   TODO Consider creating our own normalization routine, which would
             //   allow for testing on non-Windows
             String absolute = new File(path).getAbsolutePath();
+            if (absolute.length() > 2) {
+                if (absolute.charAt(1) == ':') {
+                    // Drive form
+                    root = new VirtualFile("/" + absolute.charAt(0) + ":/", null);
+                    path = absolute.substring(2).replace('\\', '/');
+                } else if (absolute.charAt(0) == '\\' && absolute.charAt(1) == '\\') {
+                    // UNC form 
+                    for (int i = 2; i < absolute.length(); i++) {
+                        if (absolute.charAt(i) == '\\') {
+                            // Switch \\ to // just like java file URLs.
+                            // Note, it turns out that File.toURL puts this portion
+                            // in the path portion of the URL, which is actually not
+                            // correct, since // is supposed to signify the authority.
+                            root = new VirtualFile("//" + absolute.substring(0,i), null);
+                            path = absolute.substring(i).replace('\\', '/');
+                            break;
+                        }
+                    }               
+                }
+            }
             
-            if (absolute.charAt(1) == ':') {
-                // Drive form
-                root = new VirtualFile("/" + absolute.charAt(0) + ":/", null);
-                path = absolute.substring(2).replace('\\', '/');
-            } else if (absolute.charAt(0) == '\\' && absolute.charAt(1) == '\\') {
-                // UNC form 
-                for (int i = 2; i < absolute.length(); i++) {
-                    if (absolute.charAt(i) == '\\') {
-                        // Switch \\ to // just like java file URLs.
-                        // Note, it turns out that File.toURL puts this portion
-                        // in the path portion of the URL, which is actually not
-                        // correct, since // is supposed to signify the authority.
-                        root = new VirtualFile("//" + absolute.substring(0,i), null);
-                        path = absolute.substring(i).replace('\\', '/');
-                        break;
-                    }
-                }               
-            } 
-            
             if (root == null)
                 throw new IllegalArgumentException("Invalid Win32 path: " + path);       
         } else {




More information about the jboss-cvs-commits mailing list