]> gitweb.factorcode.org Git - factor.git/blob - basis/io/backend/windows/windows.factor
7ecb5765a18869dc94d9c646feeb8940e9e5e691
[factor.git] / basis / io / backend / windows / windows.factor
1 ! Copyright (C) 2004, 2010 Mackenzie Straight, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types classes.struct destructors
4 io.backend io.timeouts kernel literals windows.errors
5 windows.handles windows.kernel32 vocabs.loader ;
6 IN: io.backend.windows
7
8 HOOK: CreateFile-flags io-backend ( DWORD -- DWORD )
9 HOOK: FileArgs-overlapped io-backend ( port -- overlapped/f )
10 HOOK: add-completion io-backend ( port -- port )
11
12 TUPLE: win32-file < win32-handle ptr ;
13
14 : <win32-file> ( handle -- win32-file )
15     win32-file new-win32-handle ;
16
17 M: win32-file dispose
18     [ cancel-operation ] [ call-next-method ] bi ;
19     
20 : opened-file ( handle -- win32-file )
21     check-invalid-handle <win32-file> |dispose add-completion ;
22
23 CONSTANT: share-mode
24     flags{
25         FILE_SHARE_READ
26         FILE_SHARE_WRITE
27         FILE_SHARE_DELETE
28     }
29     
30 : default-security-attributes ( -- obj )
31     SECURITY_ATTRIBUTES <struct>
32     SECURITY_ATTRIBUTES heap-size >>nLength ;
33
34 "io.files.windows" require