Working with memory-mapped data
Memory-mapped files

Prev:with-mapped-array-reader ( path c-type quot -- )
Next:Memory-mapped file examples


The <mapped-file> word returns an instance of mapped-file, which doesn't directly support the sequence protocol. Instead, it needs to be wrapped in a specialized array of the appropriate C type:
<mapped-array> ( mmap c-type -- direct-array )


Additionally, files may be opened with two combinators which take a c-type as input:
with-mapped-array ( path c-type quot -- )

with-mapped-array-reader ( path c-type quot -- )


The appropriate specialized array type must first be generated with SPECIALIZED-ARRAY:.

Data can also be read and written from the mapped-file by applying low-level alien words to the address slot. This approach is not recommended, though, since in most cases the compiler will generate efficient code for specialized array usage. See Reading and writing memory directly for a description of low-level memory access primitives.