package octez-internal-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/irmin_pack_unix/Irmin_pack_unix/Io/Unix/index.html
Module Io.Unix
Source
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
)
type open_error = [
| `Io_misc of misc_error
| `No_such_file_or_directory of string
| `Not_a_file
]
type read_error = [
| `Io_misc of misc_error
| `Read_out_of_bounds
| `Closed
| `Invalid_argument
]
type mkdir_error = [
| `Io_misc of misc_error
| `File_exists of string
| `No_such_file_or_directory of string
| `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
Write Functions
val write_string :
t ->
off:Optint.Int63.t ->
string ->
(unit, [> write_error ]) Stdlib.result
write_string t ~off s
writes s
at offset
in t
.
fsync t
persists to the file system the effects of previous create
or write.
unlink_dont_wait file
attempts to unlink the named file but doesn't wait for the completion of the unlink operation.
If unlink raises an exception it is passed to on_exn
.
Read Functions
val read_to_string :
t ->
off:Optint.Int63.t ->
len:int ->
(string, [> read_error ]) Stdlib.result
read_to_string t ~off ~len
are the len
bytes of t
at off
.
read_to_string t
is the contents full contents of the file.
The individual pages are not guaranteed to be read atomically.
read_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 of string
| `Not_a_file ])
Stdlib.result
MISC.
Unsafe Functions
These functions are equivalents to exising safe ones, but using exceptions instead of the result monad for performances reasons.
read_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).
write_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).