package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.stdlib-unix/Tezos_stdlib_unix/Lwt_utils_unix/index.html
Module Tezos_stdlib_unix.Lwt_utils_unixSource
default_net_timeout is the default timeout used by functions in this library which admit a timeout value, i.e. read_bytes_with_timeout, Socket.connect, Socket.recv.
val read_bytes_with_timeout :
?timeout:Ptime.Span.t ->
?file_offset:int ->
?pos:int ->
?len:int ->
Lwt_unix.file_descr ->
bytes ->
unit Lwt.tread_bytes_with_timeout ?timeout ?file_offset ?pos ?len fd buf reads len-pos bytes from fd into bytes. If file_offset is given, Lwt_unix.pread will be used instead of Lwt_unix.read.
val read_bytes :
?file_offset:int ->
?pos:int ->
?len:int ->
Lwt_unix.file_descr ->
bytes ->
unit Lwt.tread_bytes ?file_offset ?pos ?len fd buf reads len-pos bytes from fd into bytes. If file_offset is given, Lwt_unix.pread will be used instead of Lwt_unix.read.
val write_bytes :
?file_offset:int ->
?pos:int ->
?len:int ->
Lwt_unix.file_descr ->
Bytes.t ->
unit Lwt.twrite_bytes ?file_offset ?pos ?len fd buf writes len-pos bytes from bytes to fd. If file_offset is given, Lwt_unix.pwrite will be used instead of Lwt_unix.write.
is_directory path tests if the given path (or the target of the symbolic link located at path) refers to a directory (file kind is S_DIR).
dir_exists tests if the given path (or the target of the symbolic link located at path) is an existing directory. false is returned either if the target does not exist or if it is not a directory.
create_dir ?perm dir creates the directory at the path dir and its parents recursively if they doesn't exist
copy_dir ?perm src dst copies the content of directory src in a fresh directory dst created with perm (0o755 by default).
val getaddrinfo :
passive:bool ->
node:string ->
service:string ->
(Ipaddr.V6.t * int) list Lwt.tgetpass () reads a password from stdio while setting-up the terminal to not display the password being typed.
type 'action io_error = {action : 'action;(*action which triggerred the error.
*)unix_code : Unix.error;(*Unix code error.
*)caller : string;(*Unix function which triggerred the error.
*)arg : string;(*Argument given to the unix function: generally a path.
*)
}with_io_error aims to be used as the error type for the with_* functions below. The action type is the action which trigerred the error.
type Tezos_error_monad.Error_monad.error += | Io_error of [ `Close | `Open | `Rename ] io_error
val tzfail_of_io_error :
[ `Close | `Open | `Rename ] io_error ->
'b Tezos_error_monad.Error_monad.tzresultval with_open_file :
flags:Unix.open_flag list ->
?perm:Unix.file_perm ->
string ->
(Lwt_unix.file_descr -> 'a Lwt.t) ->
('a, [ `Open | `Close ] io_error) result Lwt.twith_open_file ~flags ~perm filename f opens the given file using Lwt_unix.open_file and passes the resulting file-descriptor to f. with_open_file ensures that the file-descriptor is closed when the promise returned by f resolves, or if f raises an exception.
See Lwt_unix.openfile for a description of the arguments, warnings, and other notes. Default values for perm is 0o640.
Exceptions raised whilst opening or closing the file are wrapped in Error. When the error is `Open, the file could not be opened, and therefore the function f has not been run. When the error is `Closed, the function f was run but the file could not be closed.
Other exceptions are reraised.
val with_open_out :
?overwrite:bool ->
string ->
(Lwt_unix.file_descr -> 'a Lwt.t) ->
('a, [ `Open | `Close ] io_error) result Lwt.twith_open_out ?overwrite filename f uses with_open_file with the flags O_WRONLY; O_CREAT; O_CLOEXEC and the default permissions. The flag O_TRUNC is added if overwrite is true, which is the case by default.
val with_atomic_open_out :
?overwrite:bool ->
string ->
?temp_dir:string ->
(Lwt_unix.file_descr -> 'a Lwt.t) ->
('a, [ `Open | `Close | `Rename ] io_error) result Lwt.twith_atomic_open_out ?(overwrite=true) filename ?temp_dir f is a wrapper around with_open_out that ensures that the data are written onto filename in an atomic way.
This function uses a temporary file stored in the temp_dir directory. Then, this temporary filed is renamed as filename.
The renaming may fail, for example if the temporary file is not on the same partition as filename.
If the renaming fails, an error `Rename is returned. See with_open_file for a description of the other errors. In that case, no write have been done on filename.
The default value of temp_dir is the same as Filename.temp_file.
val with_open_in :
string ->
(Lwt_unix.file_descr -> 'a Lwt.t) ->
('a, [> `Open | `Close ] io_error) result Lwt.twith_open_in filename f uses with_open_file with the flags O_RDONLY; O_CLOEXEC and the default permissions.