2008-02-05 14:11:36 -05:00
|
|
|
USING: continuations destructors io.buffers io.files io.backend
|
2008-05-15 06:20:42 -04:00
|
|
|
io.timeouts io.ports io.windows io.windows.files
|
|
|
|
io.windows.nt.backend windows windows.kernel32
|
|
|
|
kernel libc math threads system
|
2008-04-21 20:20:18 -04:00
|
|
|
alien.c-types alien.arrays alien.strings sequences combinators
|
2008-06-27 02:56:53 -04:00
|
|
|
combinators.short-circuit ascii splitting alien strings
|
2008-09-11 02:27:23 -04:00
|
|
|
assocs namespaces make io.files.private accessors tr ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: io.windows.nt.files
|
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt cwd
|
2008-02-05 14:11:36 -05:00
|
|
|
MAX_UNICODE_PATH dup "ushort" <c-array>
|
|
|
|
[ GetCurrentDirectory win32-error=0/f ] keep
|
2008-04-20 06:15:46 -04:00
|
|
|
utf16n alien>string ;
|
2008-02-05 14:11:36 -05:00
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt cd
|
2008-02-05 14:11:36 -05:00
|
|
|
SetCurrentDirectory win32-error=0/f ;
|
|
|
|
|
|
|
|
: unicode-prefix ( -- seq )
|
|
|
|
"\\\\?\\" ; inline
|
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt root-directory? ( path -- ? )
|
2008-03-27 17:22:24 -04:00
|
|
|
{
|
2008-09-18 18:45:15 -04:00
|
|
|
{ [ dup empty? ] [ drop f ] }
|
|
|
|
{ [ dup [ path-separator? ] all? ] [ drop t ] }
|
|
|
|
{ [ dup trim-right-separators { [ length 2 = ]
|
|
|
|
[ second CHAR: : = ] } 1&& ] [ drop t ] }
|
|
|
|
{ [ dup unicode-prefix head? ]
|
|
|
|
[ trim-right-separators length unicode-prefix length 2 + = ] }
|
|
|
|
[ drop f ]
|
|
|
|
} cond ;
|
2008-02-05 14:11:36 -05:00
|
|
|
|
2008-03-25 20:52:07 -04:00
|
|
|
ERROR: not-absolute-path ;
|
2008-05-15 02:45:32 -04:00
|
|
|
|
2008-02-05 14:11:36 -05:00
|
|
|
: root-directory ( string -- string' )
|
2008-06-27 02:56:53 -04:00
|
|
|
dup {
|
|
|
|
[ length 2 >= ]
|
|
|
|
[ second CHAR: : = ]
|
|
|
|
[ first Letter? ]
|
|
|
|
} 1&& [ 2 head ] [ not-absolute-path ] if ;
|
2008-02-05 14:11:36 -05:00
|
|
|
|
|
|
|
: prepend-prefix ( string -- string' )
|
2008-04-01 20:00:20 -04:00
|
|
|
dup unicode-prefix head? [
|
|
|
|
unicode-prefix prepend
|
|
|
|
] unless ;
|
2008-02-05 14:11:36 -05:00
|
|
|
|
2008-07-09 20:43:46 -04:00
|
|
|
TR: normalize-separators "/" "\\" ;
|
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt normalize-path ( string -- string' )
|
2008-04-01 20:51:49 -04:00
|
|
|
(normalize-path)
|
2008-07-09 20:43:46 -04:00
|
|
|
normalize-separators
|
2008-04-01 20:00:20 -04:00
|
|
|
prepend-prefix ;
|
2008-02-05 14:11:36 -05:00
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt CreateFile-flags ( DWORD -- DWORD )
|
2007-11-23 20:17:40 -05:00
|
|
|
FILE_FLAG_OVERLAPPED bitor ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-04-02 21:09:56 -04:00
|
|
|
M: winnt FileArgs-overlapped ( port -- overlapped )
|
2007-09-20 18:09:08 -04:00
|
|
|
make-overlapped ;
|
|
|
|
|
2008-05-06 05:26:46 -04:00
|
|
|
M: winnt open-append
|
|
|
|
[ dup file-info size>> ] [ drop 0 ] recover
|
2008-05-15 06:20:42 -04:00
|
|
|
>r (open-append) r> >>ptr ;
|