IO.mli 1.15 KB
Newer Older
1 2
(* Input-output utilities. *)

3
(* [try/finally] has the same semantics as in Java. *)
4 5 6

val try_finally : (unit -> 'a) -> (unit -> unit) -> 'a

7 8 9 10 11 12
(* [moving_away filename action] moves the file [filename] away (if it exists),
   performs [action], then moves the file back into place (if it was moved
   away). *)

val moving_away: string -> (unit -> 'a) -> 'a

POTTIER Francois's avatar
POTTIER Francois committed
13 14 15 16 17 18
(* [with_file filename creation action] creates the file [filename] by
   running [creation], then runs [action], and ensures that the file
   is removed in the end. *)

val with_file: string -> (unit -> unit) -> (unit -> 'a) -> 'a

POTTIER Francois's avatar
POTTIER Francois committed
19 20 21 22 23 24
(* [exhaust channel] reads all of the data that's available on [channel].
   It does not assume that the length of the data is known ahead of time.
   It does not close the channel. *)

val exhaust: in_channel -> string

25 26 27 28 29 30
(* [invoke command] invokes an external command (which expects no input)
   and returns its output, if the command succeeds. It returns [None] if
   the command fails. *)

val invoke: string -> string option

31 32 33 34 35
(* [read_whole_file filename] reads the file [filename] in text mode and
   returns its contents as a string. *)

val read_whole_file: string -> string