]> gitweb.factorcode.org Git - factor.git/blob - basis/windows/handles/handles.factor
Move win32-handle to windows.handles and update using lists to avoid pulling in the...
[factor.git] / basis / windows / handles / handles.factor
1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors destructors io.timeouts kernel windows.errors
4 windows.kernel32 windows.types ;
5 IN: windows.handles
6
7 TUPLE: win32-handle < disposable handle ;
8
9 : set-inherit ( handle ? -- )
10     [ handle>> HANDLE_FLAG_INHERIT ] dip
11     >BOOLEAN SetHandleInformation win32-error=0/f ;
12
13 : new-win32-handle ( handle class -- win32-handle )
14     new-disposable swap >>handle
15     dup f set-inherit ;
16
17 : <win32-handle> ( handle -- win32-handle )
18     win32-handle new-win32-handle ;
19
20 M: win32-handle dispose* ( handle -- )
21     handle>> CloseHandle win32-error=0/f ;
22
23 TUPLE: win32-file < win32-handle ptr ;
24
25 : <win32-file> ( handle -- win32-file )
26     win32-file new-win32-handle ;
27
28 M: win32-file dispose
29     [ cancel-operation ] [ call-next-method ] bi ;