]> gitweb.factorcode.org Git - factor.git/commitdiff
io.files.windows: add some tests cases for UNC paths. Fixes #44.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 28 Aug 2011 19:55:09 +0000 (12:55 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 28 Aug 2011 19:55:09 +0000 (12:55 -0700)
basis/io/files/windows/windows-tests.factor
basis/io/files/windows/windows.factor

index d7d9080057eb131f8c54771e2d86988c3e742502..053db2d7cd4f23e14504d8fdfca4f7c844425791 100644 (file)
@@ -36,6 +36,9 @@ IN: io.files.windows.tests
 [ t ] [ "\\\\?\\c:" root-directory? ] unit-test
 [ f ] [ "\\\\?\\c:\\bar" root-directory? ] unit-test
 
+[ "\\\\a\\b\\c\\foo.xls" ] [ "//a/b/c/foo.xls" normalize-path ] unit-test
+[ "\\\\a\\b\\c\\foo.xls" ] [ "\\\\a\\b\\c\\foo.xls" normalize-path ] unit-test
+
 [ "\\foo\\bar" ] [ "/foo/bar" normalize-path ":" split1 nip ] unit-test
 
 [ "\\\\?\\C:\\builds\\factor\\log.txt" ] [
index 4b0c8cb130e7412b3cf8aa7894717f11ffc3690d..afadf08494017c3fb09de6e1ce3748f262d335b0 100755 (executable)
@@ -324,9 +324,15 @@ M: winnt root-directory? ( path -- ? )
 
 TR: normalize-separators "/" "\\" ;
 
+<PRIVATE
+
+: unc-path? ( string -- ? )
+    [ "//" head? ] [ "\\\\" head? ] bi or ;
+
+PRIVATE>
+
 M: winnt normalize-path ( string -- string' )
-    dup [ "//" head? ] [ "\\\\" head? ] bi
-    or [
+    dup unc-path? [
         normalize-separators
     ] [
         absolute-path