1 ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: continuations destructors io.files io.files.info
4 io.backend kernel quotations system alien alien.accessors
5 accessors system vocabs.loader combinators alien.c-types ;
8 TUPLE: mapped-file address handle length disposed ;
10 HOOK: (mapped-file) os ( path length -- address handle )
12 : <mapped-file> ( path -- mmap )
13 [ normalize-path ] [ file-info size>> ] bi [ (mapped-file) ] keep
16 HOOK: close-mapped-file io-backend ( mmap -- )
18 M: mapped-file dispose* ( mmap -- ) close-mapped-file ;
20 : with-mapped-file ( path quot -- )
21 [ <mapped-file> ] dip with-disposal ; inline
24 { [ os unix? ] [ "io.mmap.unix" require ] }
25 { [ os winnt? ] [ "io.mmap.windows" require ] }