Make sure io.backend.windows loads the implementations for the generics it defines. Make windows.handles not depend on io.timeouts. Fix typo in win32-file-attributes. Fix bug in null-output word. Clean up error checking code.
parent
04be762fac
commit
7122f9fccb
|
@ -3,8 +3,8 @@ arrays assocs classes.struct combinators
|
|||
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
|
||||
|
@ -32,8 +32,8 @@ SYMBOL: master-completion-port
|
|||
: <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|| ;
|
||||
|
@ -144,4 +144,5 @@ M: winnt init-stdio
|
|||
[ init-c-stdio ]
|
||||
[ null-reader null-writer null-writer set-stdio ] if ;
|
||||
|
||||
"io.files.windows.nt" require
|
||||
winnt set-io-backend
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
! 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{
|
||||
|
@ -24,3 +30,5 @@ CONSTANT: share-mode
|
|||
: default-security-attributes ( -- obj )
|
||||
SECURITY_ATTRIBUTES <struct>
|
||||
SECURITY_ATTRIBUTES heap-size >>nLength ;
|
||||
|
||||
"io.files.windows" require
|
|
@ -2,8 +2,7 @@ USING: accessors alien.c-types alien.strings classes.struct
|
|||
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
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
! 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 )
|
||||
|
@ -98,7 +98,7 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
|||
+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 )
|
||||
|
@ -127,3 +127,5 @@ SYMBOLS: +read-only+ +hidden+ +system+
|
|||
: (set-file-times) ( handle timestamp/f timestamp/f timestamp/f -- )
|
||||
[ timestamp>FILETIME ] tri@
|
||||
SetFileTime win32-error=0/f ;
|
||||
|
||||
"io.files.windows.nt" require
|
|
@ -23,7 +23,7 @@ IN: io.launcher.windows.nt
|
|||
(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 )
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ IN: io.launcher.windows.nt
|
|||
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
|
||||
|
|
|
@ -38,7 +38,7 @@ M: win32-socket dispose* ( stream -- )
|
|||
[ empty-sockaddr/size ] [ protocol-family ] bi pick family<< ;
|
||||
|
||||
: opened-socket ( handle -- win32-socket )
|
||||
<win32-socket> |dispose dup add-completion ;
|
||||
<win32-socket> |dispose add-completion ;
|
||||
|
||||
: open-socket ( addrspec type -- win32-socket )
|
||||
[ protocol-family ] dip
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov, Doug Coleman
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel calendar timers io io.encodings accessors
|
||||
namespaces fry io.streams.null ;
|
||||
USING: accessors fry io io.encodings io.streams.null kernel
|
||||
namespaces timers ;
|
||||
IN: io.timeouts
|
||||
|
||||
GENERIC: timeout ( obj -- dt/f )
|
||||
|
|
|
@ -734,10 +734,8 @@ ERROR: windows-error n string ;
|
|||
: 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
|
||||
${
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! 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
|
||||
|
||||
|
@ -19,11 +19,3 @@ TUPLE: win32-handle < disposable handle ;
|
|||
|
||||
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 ;
|
||||
|
|
Loading…
Reference in New Issue