add windows-absolute-path? and move unit tests
parent
3dde03bb4d
commit
e39894155c
|
@ -3,7 +3,7 @@
|
||||||
USING: io.backend io.files.private io hashtables kernel math
|
USING: io.backend io.files.private io hashtables kernel math
|
||||||
memory namespaces sequences strings assocs arrays definitions
|
memory namespaces sequences strings assocs arrays definitions
|
||||||
system combinators splitting sbufs continuations io.encodings
|
system combinators splitting sbufs continuations io.encodings
|
||||||
io.encodings.binary init ;
|
io.encodings.binary init unicode.categories ;
|
||||||
IN: io.files
|
IN: io.files
|
||||||
|
|
||||||
HOOK: (file-reader) io-backend ( path -- stream )
|
HOOK: (file-reader) io-backend ( path -- stream )
|
||||||
|
@ -98,11 +98,19 @@ ERROR: no-parent-directory path ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
: windows-absolute-path? ( path -- path ? )
|
||||||
|
{
|
||||||
|
{ [ dup length 2 < ] [ f ] }
|
||||||
|
{ [ dup first2 >r Letter? r> CHAR: : = and ] [ t ] }
|
||||||
|
{ [ t ] [ f ] }
|
||||||
|
} cond ;
|
||||||
|
|
||||||
: absolute-path? ( path -- ? )
|
: absolute-path? ( path -- ? )
|
||||||
{
|
{
|
||||||
{ [ dup empty? ] [ f ] }
|
{ [ dup empty? ] [ f ] }
|
||||||
{ [ dup "resource:" head? ] [ t ] }
|
{ [ dup "resource:" head? ] [ t ] }
|
||||||
{ [ dup first path-separator? ] [ t ] }
|
{ [ dup first path-separator? ] [ t ] }
|
||||||
|
{ [ windows? ] [ windows-absolute-path? ] }
|
||||||
{ [ t ] [ f ] }
|
{ [ t ] [ f ] }
|
||||||
} cond nip ;
|
} cond nip ;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
USING: kernel tools.test ;
|
||||||
|
IN: io.windows.nt.files.tests
|
||||||
|
|
||||||
|
[ f ] [ "" root-directory? ] unit-test
|
||||||
|
[ t ] [ "\\" root-directory? ] unit-test
|
||||||
|
[ t ] [ "\\\\" root-directory? ] unit-test
|
||||||
|
[ t ] [ "\\\\\\\\\\\\" root-directory? ] unit-test
|
||||||
|
[ t ] [ "/" root-directory? ] unit-test
|
||||||
|
[ t ] [ "//" root-directory? ] unit-test
|
||||||
|
[ t ] [ "//////////////" root-directory? ] unit-test
|
||||||
|
[ t ] [ "\\foo" absolute-path? ] unit-test
|
Loading…
Reference in New Issue