1 USING: continuations destructors io.buffers io.files io.backend
2 io.timeouts io.ports io.windows io.windows.files
3 io.windows.nt.backend windows windows.kernel32
4 kernel libc math threads system
5 alien.c-types alien.arrays alien.strings sequences combinators
6 combinators.short-circuit ascii splitting alien strings
7 assocs namespaces make io.files.private accessors tr ;
8 IN: io.windows.nt.files
11 MAX_UNICODE_PATH dup "ushort" <c-array>
12 [ GetCurrentDirectory win32-error=0/f ] keep
16 SetCurrentDirectory win32-error=0/f ;
18 : unicode-prefix ( -- seq )
21 M: winnt root-directory? ( path -- ? )
23 { [ dup empty? ] [ drop f ] }
24 { [ dup [ path-separator? ] all? ] [ drop t ] }
25 { [ dup trim-right-separators { [ length 2 = ]
26 [ second CHAR: : = ] } 1&& ] [ drop t ] }
27 { [ dup unicode-prefix head? ]
28 [ trim-right-separators length unicode-prefix length 2 + = ] }
32 ERROR: not-absolute-path ;
34 : root-directory ( string -- string' )
39 } 1&& [ 2 head ] [ not-absolute-path ] if ;
41 : prepend-prefix ( string -- string' )
42 dup unicode-prefix head? [
43 unicode-prefix prepend
46 TR: normalize-separators "/" "\\" ;
48 M: winnt normalize-path ( string -- string' )
53 M: winnt CreateFile-flags ( DWORD -- DWORD )
54 FILE_FLAG_OVERLAPPED bitor ;
56 M: winnt FileArgs-overlapped ( port -- overlapped )
60 [ dup file-info size>> ] [ drop 0 ] recover
61 >r (open-append) r> >>ptr ;