with-mapped-array ( path c-type quot -- ) (original) (raw)

Vocabulary
io.mmap

Inputs

path a pathname string
c-type a c-type
quot a quotation

Outputs
None

Word description
Memory-maps a file for reading and writing, wrapping it in a specialized array with the given element type. The mapped file is disposed of when the quotation returns, or if an error is thrown.

Examples

USING: alien.c-types io.mmap prettyprint specialized-arrays ; SPECIALIZED-ARRAY: uint resource:LICENSE.txt" uint [ [ . ] each ] with-mapped-array

Errors
Throws an error if a memory mapping could not be established.

Definition

USING: io.mmap.private kernel ;

IN: io.mmap

: with-mapped-array ( path c-type quot -- )
[ ] 2dip (with-mapped-array) ; inline