 io.timeouts io.nonblocking io.windows io.windows.nt.backend
 kernel libc math threads windows windows.kernel32
 alien.c-types alien.arrays sequences combinators combinators.lib
-sequences.lib ascii splitting alien strings assocs ;
+sequences.lib ascii splitting alien strings assocs
+combinators.cleave ;
 IN: io.windows.nt.files
 
 M: windows-nt-io cwd


M: windows-nt-io root-directory? ( path -- ? )
    dup length 2 = [
        dup first Letter?
        swap second CHAR: : = and
    ] [
        drop f
    ] if ;

: root-directory ( string -- string' )
    {
        [ dup length 2 >= ]
        [ dup second CHAR: : = ]
        [ dup first Letter? ]
    } && [ 2 head ] [ "Not an absolute path" throw ] if ;

: prepend-prefix ( string -- string' )
    unicode-prefix prepend ;

        ] }
    } cond ;

ERROR: nonstring-pathname ;
ERROR: empty-pathname ;

M: windows-nt-io normalize-pathname ( string -- string )
    dup string? [ nonstring-pathname ] unless
    dup empty? [ empty-pathname ] when
    { { CHAR: / CHAR: \\ } } substitute
    cwd swap windows-append-path
    [ "/\\." member? ] right-trim
