! Copyright (C) 2008 Doug Coleman, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.data alien.strings libc destructors
-locals kernel math assocs namespaces make continuations sequences
-hashtables sorting arrays combinators math.bitwise strings
-system accessors threads splitting io.backend
-io.files.windows io.monitors io.ports
-io.buffers io.files io.timeouts io.encodings.string literals
-io.encodings.utf16n io windows.errors windows.kernel32 windows.types
-io.pathnames classes.struct ;
+USING: accessors alien alien.data arrays classes.struct
+combinators continuations destructors fry io.backend
+io.encodings.string io.encodings.utf16 io.files.windows
+io.monitors io.pathnames io.ports kernel literals locals make
+math sequences system threads windows.errors windows.kernel32
+windows.types ;
IN: io.monitors.windows
: open-directory ( path -- handle )
[ recursive>> 1 0 ? ]
} cleave
FILE_NOTIFY_CHANGE_ALL
- 0 uint <ref>
+ 0 DWORD <ref>
(make-overlapped)
[ f ReadDirectoryChangesW win32-error=0/f ] keep ;
memory>byte-array utf16n decode ;
: parse-notify-record ( buffer -- path changed )
- [ [ FileName>> ] [ FileNameLength>> ] bi memory>u16-string ]
- [ Action>> parse-action ] bi ;
+ [
+ [ FileName>> ] [ FileNameLength>> ] bi memory>u16-string
+ ] [ Action>> parse-action ] bi ;
: (file-notify-records) ( buffer -- buffer )
FILE_NOTIFY_INFORMATION memory>struct
] each ;
: fill-queue ( monitor -- )
- dup port>> dup check-disposed
+ dup port>> check-disposed
[ buffer>> ptr>> ] [ read-changes zero? ] bi
[ 2dup parse-notify-records ] unless
2drop ;
dup fill-queue (fill-queue-thread) ;
: fill-queue-thread ( monitor -- )
- [ dup fill-queue (fill-queue-thread) ]
- [ dup already-disposed? [ 2drop ] [ rethrow ] if ] recover ;
+ '[ _ dup fill-queue (fill-queue-thread) ]
+ [ already-disposed? ] ignore-error ;
-M:: winnt (monitor) ( path recursive? mailbox -- monitor )
+M:: windows (monitor) ( path recursive? mailbox -- monitor )
[
path normalize-path mailbox win32-monitor new-monitor
path open-directory \ win32-monitor-port <buffered-port>