1 ! Copyright (C) 2007 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien io io.files kernel math math.bitwise system unix
4 io.backend.unix io.ports io.mmap destructors locals accessors ;
7 : open-r/w ( path -- fd ) O_RDWR file-mode open-file ;
9 :: mmap-open ( path length prot flags -- alien fd )
12 path open-r/w |dispose
13 [ 0 mmap dup MAP_FAILED = [ (io-error) ] when ] keep
17 { PROT_READ PROT_WRITE } flags
18 { MAP_FILE MAP_SHARED } flags
21 M: unix close-mapped-file ( mmap -- )
22 [ [ address>> ] [ length>> ] bi munmap io-error ]
23 [ handle>> close-file ]