Library
Module
Module type
Parameter
Class
Class type
A collection of extensions to the Unix
module.
val mkdir_safe : string -> Unix.file_perm -> unit
val mkdir_rec : string -> Unix.file_perm -> unit
removes a file or recursively removes files/directories below a directory without following symbolic links. If path is a directory, it is only itself removed if rm_top is true. If path is non-existent nothing happens, it does not lead to an error.
val with_file :
string ->
Unix.open_flag list ->
Unix.file_perm ->
(Unix.file_descr -> 'a) ->
'a
val with_input_channel : string -> (in_channel -> 'a) -> 'a
val with_directory : string -> (Unix.dir_handle -> 'a) -> 'a
val lines_fold : ('a -> string -> 'a) -> 'a -> in_channel -> 'a
Folds function f
over every line in the input channel
val lines_iter : (string -> unit) -> in_channel -> unit
Applies function f
to every line in the input channel
Folds function f
over every line in the file at file_path
using the starting value start
.
read_lines path
returns a list of lines in the file at path
.
Applies function f
to every line in the file at file_path
.
val fd_blocks_fold : int -> ('a -> bytes -> 'a) -> 'a -> Unix.file_descr -> 'a
fd_blocks_fold block_size f start fd
folds f
over blocks (strings) from the fd fd
with initial value start
val buffer_of_fd : Unix.file_descr -> Buffer.t
buffer_of_fd fd
returns a Buffer.t containing all data read from fd
up to EOF
val string_of_fd : Unix.file_descr -> string
string_of_fd fd
returns a string containing all data read from fd
up to EOF
val buffer_of_file : string -> Buffer.t
buffer_of_file file
returns a Buffer.t containing the contents of file
string_of_file file
returns a string containing the contents of file
val atomic_write_to_file :
string ->
Unix.file_perm ->
(Unix.file_descr -> 'a) ->
'a
atomic_write_to_file fname perms f
writes a file to path fname
using the function f
with permissions perms
. In case of error during the operation the file with the path fname
is not modified at all.
val write_string_to_file : ?perms:Unix.file_perm -> string -> string -> unit
write_string_to_file fname contents
creates a file with path fname
with the string contents
as its contents, atomically
val write_bytes_to_file : ?perms:Unix.file_perm -> string -> bytes -> unit
write_string_to_file fname contents
creates a file with path fname
with the buffer contents
as its contents, atomically
val execv_get_output : string -> string array -> int * Unix.file_descr
val copy_file : ?limit:int64 -> Unix.file_descr -> Unix.file_descr -> int64
Sets both the access and modification times of the file * at the given path to the current time. Creates an empty * file at the given path if no such file already exists.
Returns true if and only if an empty file exists at the given path.
Safely deletes a file at the given path if (and only if) the * file exists and is empty. Returns true if a file was deleted.
val open_connection_fd : string -> int -> Unix.file_descr
val open_connection_unix_fd : string -> Unix.file_descr
string_of_signal x
translates an ocaml signal number into * a string suitable for logging.
val proxy : Unix.file_descr -> Unix.file_descr -> unit
val really_read : Unix.file_descr -> bytes -> int -> int -> unit
val really_read_string : Unix.file_descr -> int -> string
val really_write : Unix.file_descr -> string -> int -> int -> unit
really_write
keeps repeating the write operation until all bytes * have been written or an error occurs. This is not atomic but is * robust against EINTR errors. * See: https://ocaml.github.io/ocamlunix/ocamlunix.html#sec118
val really_write_string : Unix.file_descr -> string -> unit
val try_read_string : ?limit:int -> Unix.file_descr -> string
val time_limited_write : Unix.file_descr -> int -> bytes -> float -> unit
val time_limited_write_substring :
Unix.file_descr ->
int ->
string ->
float ->
unit
val time_limited_read : Unix.file_descr -> int -> float -> string
val read_data_in_string_chunks :
(string -> int -> unit) ->
?block_size:int ->
?max_bytes:int ->
Unix.file_descr ->
int
val read_data_in_chunks :
(bytes -> int -> unit) ->
?block_size:int ->
?max_bytes:int ->
Unix.file_descr ->
int
val spawnvp :
?pid_callback:(int -> unit) ->
string ->
string array ->
Unix.process_status
val set_tcp_nodelay : Unix.file_descr -> bool -> unit
val set_sock_keepalives : Unix.file_descr -> int -> int -> int -> unit
val fsync : Unix.file_descr -> unit
val blkgetsize64 : Unix.file_descr -> int64
val int_of_file_descr : Unix.file_descr -> int
val file_descr_of_int : int -> Unix.file_descr
val close_all_fds_except : Unix.file_descr list -> unit
val seek_to : Unix.file_descr -> int -> int
val seek_rel : Unix.file_descr -> int -> int
val current_cursor_pos : Unix.file_descr -> int
val send_fd :
Unix.file_descr ->
bytes ->
int ->
int ->
Unix.msg_flag list ->
Unix.file_descr ->
int
val send_fd_substring :
Unix.file_descr ->
string ->
int ->
int ->
Unix.msg_flag list ->
Unix.file_descr ->
int
val recv_fd :
Unix.file_descr ->
bytes ->
int ->
int ->
Unix.msg_flag list ->
int * Unix.sockaddr * Unix.file_descr
val statvfs : string -> statvfs_t
val domain_of_addr : string -> Unix.socket_domain option
Returns Some Unix.PF_INET or Some Unix.PF_INET6 if passed a valid IP address, otherwise returns None.
module Direct : sig ... end
Perform I/O in O_DIRECT mode using 4KiB page-aligned buffers