1 ! Copyright (C) 2004, 2008 Mackenzie Straight, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types arrays destructors io io.backend
4 io.buffers io.files io.ports io.binary io.timeouts
5 windows.errors strings kernel math namespaces sequences windows
6 windows.kernel32 windows.shell32 windows.types windows.winsock
7 splitting continuations math.bitwise system accessors ;
10 : set-inherit ( handle ? -- )
11 [ HANDLE_FLAG_INHERIT ] dip
12 >BOOLEAN SetHandleInformation win32-error=0/f ;
14 TUPLE: win32-handle handle disposed ;
16 : new-win32-handle ( handle class -- win32-handle )
17 new swap [ >>handle ] [ f set-inherit ] bi ;
19 : <win32-handle> ( handle -- win32-handle )
20 win32-handle new-win32-handle ;
22 M: win32-handle dispose* ( handle -- )
23 handle>> CloseHandle drop ;
25 TUPLE: win32-file < win32-handle ptr ;
27 : <win32-file> ( handle -- win32-file )
28 win32-file new-win32-handle ;
31 dup disposed>> [ drop ] [
32 [ cancel-operation ] [ call-next-method ] bi
35 HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
36 HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
37 HOOK: add-completion io-backend ( port -- )
39 : opened-file ( handle -- win32-file )
44 : share-mode ( -- fixnum )
51 : default-security-attributes ( -- obj )
52 "SECURITY_ATTRIBUTES" <c-object>
53 "SECURITY_ATTRIBUTES" heap-size
54 over set-SECURITY_ATTRIBUTES-nLength ;