module Mmap:Accessing memory-mapped files as strings.sig
..end
This module allows one to map files into memory and access
them byte by byte, or by extracing or blitting substrings.
type
t
val map : ?write:bool ->
?copy:bool -> ?offset:int64 -> ?length:int64 -> Unix.file_descr -> t
map fd copy offset length
maps the bytes offset .. offset + length - 1
of file fd
;
if copy
is true, the file is mapped in copy-on-write mode.val unmap : t -> unit
unmap mp
removes the mapping mp
; all subsequent calls with mp
will raise an Invalid_argument
exception.val sub : t -> int64 -> int -> string
sub mp o n
copies the bytes from offset + o
to offset + o + n
into a new stringval length : t -> int64
val offset : t -> int64
val blit : t -> int64 -> string -> int -> int -> unit
blit mp i u j n
copies the bytes
j
to j + n - 1
of the string u
into the bytes offset + i
to offset + i + n - 1
of the map.val paste : t -> int64 -> string -> unit
paste mp i u
copies the string u
into the bytes offset + i
to offset + i + n - 1
of the map, where n
is the length of the string u
.