Module type Pvem_lwt_unix.IO

module type IO = sig .. end


Useful I/O functions.
type path = string 
The type of file paths

Whole Files


val write_file : path ->
content:string ->
(unit, [> `IO of [> `Write_file_exn of path * exn ] ])
Pvem_lwt_unix.Deferred_result.t
Write a string to a file.
val read_file : path ->
(string, [> `IO of [> `Read_file_exn of path * exn ] ])
Pvem_lwt_unix.Deferred_result.t
Read a string from a file.

Access To Channels


val with_out_channel : ?buffer_size:int ->
f:(Lwt_io.output_channel ->
('a,
[> `IO of
[> `Exn of exn | `File_exists of string | `Wrong_path of string ] ]
as 'err)
Pvem_lwt_unix.Deferred_result.t) ->
[ `Append_to_file of string
| `Channel of Lwt_io.output_channel
| `Create_file of string
| `Overwrite_file of string
| `Stderr
| `Stdout ] -> ('a, 'err) Pvem_lwt_unix.Deferred_result.t
Run a function f on an output channel, if the channel comes from a `File f, it will be closed before returning (in case of success, or error, but not for exceptions).
val write : Lwt_io.output_channel ->
string ->
(unit, [> `IO of [> `Exn of exn ] ]) Pvem_lwt_unix.Deferred_result.t
Safely call Lwt_io.fprint.
val flush : Lwt_io.output_channel ->
(unit, [> `IO of [> `Exn of exn ] ]) Pvem_lwt_unix.Deferred_result.t
Flush an output channel.
val with_in_channel : [ `Channel of Lwt_io.input_channel | `File of string | `Stdin ] ->
?buffer_size:int ->
f:(Lwt_io.input_channel ->
('a, [> `IO of [> `Exn of exn ] ] as 'err) Pvem_lwt_unix.Deferred_result.t) ->
('a, 'err) Pvem_lwt_unix.Deferred_result.t
Run a function f on an input channel, if the channel comes from a `File f, it will be closed before returning (in case of success, or error, but not for exceptions).
val read : ?count:int ->
Lwt_io.input_channel ->
(string, [> `IO of [> `Exn of exn ] ]) Pvem_lwt_unix.Deferred_result.t
Read count bytes from an input-channel (default: “as much as possible”, c.f. Lwt_io.read).
val error_to_string : [< `IO of
[< `Exn of exn
| `File_exists of string
| `Read_file_exn of string * exn
| `Write_file_exn of string * exn
| `Wrong_path of string ] ] ->
string
Get a human-readable string out of an error produced by this module.