Commit a73f953b authored by POTTIER Francois's avatar POTTIER Francois

Removed [IO.winvoke].

parent 1f86d37d
......@@ -29,6 +29,15 @@ let moving_away filename action =
else
action()
(* ------------------------------------------------------------------------- *)
(* [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. *)
let with_file filename creation action =
creation();
try_finally action (fun () -> Sys.remove filename)
(* ------------------------------------------------------------------------- *)
(* [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.
......@@ -68,26 +77,3 @@ let invoke command =
| _ ->
None
(* ------------------------------------------------------------------------- *)
(* [winvoke writers command cleaners] invokes each of the [writer]
functions, invokes the command [command], and runs each of the
[cleaner] functions. Then, it either returns the command's output,
if the command succeeded, or exits, otherwise. *)
let winvoke writers command cleaners =
let call action =
action ()
in
List.iter call writers;
let output = invoke command in
List.iter call cleaners;
(* Stop if the command failed. Otherwise, return its output. *)
match output with
| None ->
(* Presumably, the command printed an error message for us. *)
exit 1
| Some output ->
output
......@@ -10,6 +10,12 @@ val try_finally : (unit -> 'a) -> (unit -> unit) -> 'a
val moving_away: string -> (unit -> 'a) -> 'a
(* [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
(* [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. *)
......@@ -22,10 +28,3 @@ val exhaust: in_channel -> string
val invoke: string -> string option
(* [winvoke writers command cleaners] invokes each of the [writer]
functions, invokes the command [command], and runs each of the
[cleaner] functions. Then, it either returns the command's output,
if the command succeeded, or exits, otherwise. *)
val winvoke: (unit -> unit) list -> string -> (unit -> unit) list -> string
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment