combinators.short-circuit destructors io io.backend
io.backend.windows io.buffers io.files.windows io.ports
io.streams.c io.streams.null io.timeouts kernel libc locals
-math namespaces sequences system threads windows.errors
-windows.handles windows.kernel32 ;
+math namespaces sequences system threads vocabs.loader
+windows.errors windows.handles windows.kernel32 ;
IN: io.backend.windows.nt
! Global variable with assoc mapping overlapped to threads
: <master-completion-port> ( -- handle )
INVALID_HANDLE_VALUE f <completion-port> ;
-M: winnt add-completion ( win32-handle -- )
- handle>> master-completion-port get-global <completion-port> drop ;
+M: winnt add-completion ( win32-handle -- win32-handle )
+ dup handle>> master-completion-port get-global <completion-port> drop ;
: eof? ( error -- ? )
{ [ ERROR_HANDLE_EOF = ] [ ERROR_BROKEN_PIPE = ] } 1|| ;
[ init-c-stdio ]
[ null-reader null-writer null-writer set-stdio ] if ;
+"io.files.windows.nt" require
winnt set-io-backend
! Copyright (C) 2004, 2010 Mackenzie Straight, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types classes.struct destructors
-io.backend kernel literals windows.errors windows.handles
-windows.kernel32 ;
+io.backend io.timeouts kernel literals windows.errors
+windows.handles windows.kernel32 vocabs.loader ;
IN: io.backend.windows
HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
-HOOK: add-completion io-backend ( port -- )
+HOOK: add-completion io-backend ( port -- port )
+TUPLE: win32-file < win32-handle ptr ;
+
+: <win32-file> ( handle -- win32-file )
+ win32-file new-win32-handle ;
+
+M: win32-file dispose
+ [ cancel-operation ] [ call-next-method ] bi ;
+
: opened-file ( handle -- win32-file )
- dup invalid-handle?
- <win32-file> |dispose
- dup add-completion ;
+ check-invalid-handle <win32-file> |dispose add-completion ;
CONSTANT: share-mode
flags{
: default-security-attributes ( -- obj )
SECURITY_ATTRIBUTES <struct>
SECURITY_ATTRIBUTES heap-size >>nLength ;
+
+"io.files.windows" require
\ No newline at end of file
combinators combinators.short-circuit continuations environment
io.backend io.backend.windows io.encodings.utf16n
io.files.private io.files.windows io.pathnames kernel math
-sequences specialized-arrays
-specialized-arrays.instances.alien.c-types.ushort system tr
+sequences specialized-arrays system tr
windows windows.errors windows.kernel32 windows.shell32
windows.time ;
SPECIALIZED-ARRAY: ushort
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data combinators
destructors io.backend.windows io.binary io.buffers io.files
-io.files.types io.ports kernel literals make math.bitwise
-system windows.errors windows.handles windows.kernel32
-windows.time windows.types ;
+io.files.types io.ports kernel literals make
+math.bitwise system windows.errors windows.handles
+windows.kernel32 windows.time windows.types vocabs.loader ;
IN: io.files.windows
: open-file ( path access-mode create-mode flags -- handle )
+sparse-file+ +reparse-point+ +compressed+ +offline+
+not-content-indexed+ +encrypted+ ;
-: win32-file-attribute ( n attr symbol -- )
+: win32-file-attribute ( n symbol attr -- )
rot mask? [ , ] [ drop ] if ;
: win32-file-attributes ( n -- seq )
: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- )
[ timestamp>FILETIME ] tri@
SetFileTime win32-error=0/f ;
+
+"io.files.windows.nt" require
\ No newline at end of file
(pipe) [ in>> &dispose ] [ out>> dispose ] bi ;
: null-output ( -- pipe )
- (pipe) [ in>> dispose ] [ out>> &dispose ] bi ;
+ (pipe) [ out>> &dispose ] [ in>> dispose ] bi ;
: null-pipe ( mode -- pipe )
{
create-mode
FILE_ATTRIBUTE_NORMAL ! flags and attributes
f ! template file
- CreateFile dup invalid-handle? <win32-file> &dispose ;
+ CreateFile check-invalid-handle <win32-file> &dispose ;
: redirect-append ( path access-mode create-mode -- handle )
[ path>> ] 2dip
[ empty-sockaddr/size ] [ protocol-family ] bi pick family<< ;\r
\r
: opened-socket ( handle -- win32-socket )\r
- <win32-socket> |dispose dup add-completion ;\r
+ <win32-socket> |dispose add-completion ;\r
\r
: open-socket ( addrspec type -- win32-socket )\r
[ protocol-family ] dip\r
! Copyright (C) 2008 Slava Pestov, Doug Coleman\r
! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel calendar timers io io.encodings accessors\r
-namespaces fry io.streams.null ;\r
+USING: accessors fry io io.encodings io.streams.null kernel\r
+namespaces timers ;\r
IN: io.timeouts\r
\r
GENERIC: timeout ( obj -- dt/f )\r
: win32-error<0 ( n -- ) 0 < [ win32-error ] when ;
: win32-error<>0 ( n -- ) zero? [ win32-error ] unless ;
-: invalid-handle? ( handle -- )
- INVALID_HANDLE_VALUE = [
- win32-error-string throw
- ] when ;
+: check-invalid-handle ( handle -- handle )
+ dup INVALID_HANDLE_VALUE = [ win32-error-string throw ] when ;
CONSTANT: expected-io-errors
${
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors destructors io.timeouts kernel windows.errors
+USING: accessors destructors kernel windows.errors
windows.kernel32 windows.types ;
IN: windows.handles
M: win32-handle dispose* ( handle -- )
handle>> CloseHandle win32-error=0/f ;
-
-TUPLE: win32-file < win32-handle ptr ;
-
-: <win32-file> ( handle -- win32-file )
- win32-file new-win32-handle ;
-
-M: win32-file dispose
- [ cancel-operation ] [ call-next-method ] bi ;