From 19555da91c6e90f198afb07dc2d7b56da7b45a4e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Jan 2008 01:21:44 -0600 Subject: [PATCH] Non-blocking directory change notification support for Windows --- extra/io/windows/nt/backend/backend.factor | 7 +----- extra/io/windows/nt/monitor/monitor.factor | 25 +++++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/extra/io/windows/nt/backend/backend.factor b/extra/io/windows/nt/backend/backend.factor index 0aaa935a7e..3b10ddd935 100755 --- a/extra/io/windows/nt/backend/backend.factor +++ b/extra/io/windows/nt/backend/backend.factor @@ -48,12 +48,7 @@ TUPLE: io-callback port continuation ; C: io-callback : (make-overlapped) ( -- overlapped-ext ) - "OVERLAPPED" malloc-object dup free-always - 0 over set-OVERLAPPED-internal - 0 over set-OVERLAPPED-internal-high - 0 over set-OVERLAPPED-offset-high - 0 over set-OVERLAPPED-offset - f over set-OVERLAPPED-event ; + "OVERLAPPED" malloc-object dup free-always ; : make-overlapped ( port -- overlapped-ext ) >r (make-overlapped) r> port-handle win32-file-ptr diff --git a/extra/io/windows/nt/monitor/monitor.factor b/extra/io/windows/nt/monitor/monitor.factor index c8714b33cc..bd3debecad 100755 --- a/extra/io/windows/nt/monitor/monitor.factor +++ b/extra/io/windows/nt/monitor/monitor.factor @@ -37,21 +37,20 @@ M: windows-nt-io ( path recursive? -- monitor ) M: windows-nt-io close-monitor ( monitor -- ) stream-close ; : begin-reading-changes ( monitor -- overlapped ) - [ - dup port-handle win32-file-handle - over buffer-ptr - pick buffer-size - roll monitor-recursive? 1 0 ? - FILE_NOTIFY_CHANGE_ALL - 0 - f - (make-overlapped) - [ ReadDirectoryChangesW win32-error=0/f ] keep - ] with-destructors ; + dup port-handle win32-file-handle + over buffer-ptr + pick buffer-size + roll monitor-recursive? 1 0 ? + FILE_NOTIFY_CHANGE_ALL + 0 + (make-overlapped) + [ f ReadDirectoryChangesW win32-error=0/f ] keep ; : read-changes ( monitor -- bytes ) - dup begin-reading-changes swap [ save-callback ] 2keep - get-overlapped-result ; + [ + dup begin-reading-changes swap [ save-callback ] 2keep + get-overlapped-result + ] with-destructors ; : parse-action-flag ( action mask symbol -- action ) >r over bitand 0 > [ r> , ] [ r> drop ] if ;