diff --git a/extra/io/windows/directory/directory.factor b/extra/io/windows/directory/directory.factor new file mode 100644 index 0000000000..4728a063a0 --- /dev/null +++ b/extra/io/windows/directory/directory.factor @@ -0,0 +1,34 @@ +USING: alien.c-types destructors io.windows +io.windows.nt.backend kernel math windows +windows.kernel32 windows.types libc ; +IN: io.windows.directory + +: open-directory ( path -- handle ) + [ + FILE_LIST_DIRECTORY + share-mode + f + OPEN_EXISTING + FILE_FLAG_BACKUP_SEMANTICS FILE_FLAG_OVERLAPPED bitor + f + CreateFile + dup invalid-handle? dup close-later + dup add-completion + ] with-destructors ; + +: directory-notifications ( -- n ) + FILE_NOTIFY_CHANGE_FILE_NAME FILE_NOTIFY_CHANGE_DIR_NAME bitor ; + +: read-directory-changes ( handle -- ) + [ + 65536 dup malloc + swap + TRUE + directory-notifications + 0 + (make-overlapped) + ! f works here, blocking + f + ReadDirectoryChangesW win32-error=0/f + ] with-destructors ; + diff --git a/extra/io/windows/nt/backend/backend.factor b/extra/io/windows/nt/backend/backend.factor index 0d1f2cec0b..c107c36b5a 100755 --- a/extra/io/windows/nt/backend/backend.factor +++ b/extra/io/windows/nt/backend/backend.factor @@ -132,7 +132,11 @@ M: windows-nt-io add-completion ( handle -- ) ] if ] if ] [ - lookup-callback io-callback-continuation + lookup-callback [ + io-callback-continuation + ] [ + "unhandled io event" print flush f + ] if* ] if ; : maybe-expire ( io-callbck -- )