From 39b800907c5fe129d8bc6119889f6a65cbb08f55 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 28 Aug 2011 12:55:09 -0700 Subject: [PATCH] io.files.windows: add some tests cases for UNC paths. Fixes #44. --- basis/io/files/windows/windows-tests.factor | 3 +++ basis/io/files/windows/windows.factor | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/basis/io/files/windows/windows-tests.factor b/basis/io/files/windows/windows-tests.factor index d7d9080057..053db2d7cd 100644 --- a/basis/io/files/windows/windows-tests.factor +++ b/basis/io/files/windows/windows-tests.factor @@ -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" ] [ diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor index 4b0c8cb130..afadf08494 100755 --- a/basis/io/files/windows/windows.factor +++ b/basis/io/files/windows/windows.factor @@ -324,9 +324,15 @@ M: winnt root-directory? ( path -- ? ) TR: normalize-separators "/" "\\" ; + + M: winnt normalize-path ( string -- string' ) - dup [ "//" head? ] [ "\\\\" head? ] bi - or [ + dup unc-path? [ normalize-separators ] [ absolute-path