package irmin-pack
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=2a1e6a7577e498fbfeb678d666da210dc48d1344637e8ecb653e1dd88c640b5f
sha512=3fb6f49a1af2f8bab1df5b6f5affaaa09f09fe892a08eb2d9de58138e56646d4a6797f3c087b22875e36e3411218ab2435fe5437ac78f323dd661932af021fad
doc/irmin-pack.unix/Irmin_pack_unix/Mapping_file/Make/argument-1-Io/index.html
Parameter Make.Io
Low level IO abstraction. A typical implementation is unix. This abstraction is meant to be dead simple. Not a lot of documentation is required.
It is not resistant to race condictions. There should not be concurrent modifications of the files.
These functions are essentially invoking the underlying functions from Unix directly; there is no buffering for example.
Errors
An abstract error type that contains the IO-backend specific errors. (e.g. Unix.error)
val misc_error_t : misc_error Irmin.Type.ttype mkdir_error = [ | `Io_misc of misc_error| `File_exists of string| `No_such_file_or_directory| `Invalid_parent_directory
]Safe Functions
None of the functions in this section raise exceptions. They may however perform effects that are always continued.
Life Cycle
val create : path:string -> overwrite:bool -> (t, [> create_error ]) resultval open_ : path:string -> readonly:bool -> (t, [> open_error ]) resultval close : t -> (unit, [> close_error ]) resultWrite Functions
val write_string :
t ->
off:Optint.Int63.t ->
string ->
(unit, [> write_error ]) resultwrite_string t ~off s writes s at offset in t.
val fsync : t -> (unit, [> write_error ]) resultfsync t persists to the file system the effects of previous create or write.
val move_file :
src:string ->
dst:string ->
(unit, [> `Sys_error of string ]) resultval copy_file :
src:string ->
dst:string ->
(unit, [> `Sys_error of string ]) resultval mkdir : string -> (unit, [> mkdir_error ]) resultval unlink : string -> (unit, [> `Sys_error of string ]) resultRead Functions
val read_to_string :
t ->
off:Optint.Int63.t ->
len:int ->
(string, [> read_error ]) resultread_to_string t ~off ~len are the len bytes of t at off.
val read_all_to_string :
t ->
(string, [> `Io_misc of misc_error | `Closed ]) resultread_to_string t is the contents full contents of the file.
The individual pages are not guaranteed to be read atomically.
val read_size : t -> (Optint.Int63.t, [> read_error ]) resultread_size t is the number of bytes of the file handled by t.
This function is expensive in the unix implementation because it performs syscalls.
val size_of_path :
string ->
(Optint.Int63.t,
[> `Io_misc of misc_error | `No_such_file_or_directory | `Not_a_file ])
resultMISC.
val readonly : t -> boolval path : t -> stringUnsafe Functions
These functions are equivalents to exising safe ones, but using exceptions instead of the result monad for performances reasons.
val read_exn : t -> off:Optint.Int63.t -> len:int -> bytes -> unitread_exn t ~off ~len b reads the len bytes of t at off to b.
Raises Errors.Pack_error and Errors.RO_not_allowed.
Also raises backend-specific exceptions (e.g. Unix.Unix_error for the unix backend).
val write_exn : t -> off:Optint.Int63.t -> len:int -> string -> unitwrite_exn t ~off ~len b writes the first len bytes pf b to t at offset off.
Raises Errors.Pack_error and Errors.RO_not_allowed.
Also raises backend-specific exceptions (e.g. Unix.Unix_error for the unix backend).
val raise_misc_error : misc_error -> 'aval catch_misc_error : (unit -> 'a) -> ('a, [> `Io_misc of misc_error ]) result