1 USING: continuations destructors io.buffers io.files io.backend
2 io.timeouts io.ports io.files.private io.windows
3 io.windows.files io.windows.nt.backend io.encodings.utf16n
4 windows windows.kernel32 kernel libc math threads system
5 environment alien.c-types alien.arrays alien.strings sequences
6 combinators combinators.short-circuit ascii splitting alien
7 strings assocs namespaces make 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 M: winnt root-directory ( string -- string' )
35 unicode-prefix ?head drop
40 } 1&& [ 2 head "\\" append ] [ not-absolute-path ] if ;
42 : prepend-prefix ( string -- string' )
43 dup unicode-prefix head? [
44 unicode-prefix prepend
47 TR: normalize-separators "/" "\\" ;
49 M: winnt normalize-path ( string -- string' )
54 M: winnt CreateFile-flags ( DWORD -- DWORD )
55 FILE_FLAG_OVERLAPPED bitor ;
57 M: winnt FileArgs-overlapped ( port -- overlapped )
61 [ dup file-info size>> ] [ drop 0 ] recover
62 [ (open-append) ] dip >>ptr ;
64 M: winnt home "USERPROFILE" os-env ;