module Command:sig
..end
Useful high-level system operations.
val filename : string -> string -> string
val pp_to_file : string -> (Format.formatter -> unit) -> unit
pp_to_file file pp
runs pp
on a formatter that writes into file
.
The formatter is always properly flushed and closed on return.
Exceptions in pp
are re-raised after closing.
val pp_from_file : Format.formatter -> string -> unit
pp_from_file fmt file
dumps the content of file
into the fmt
.
Exceptions in pp
are re-raised after closing.
val bincopy : bytes -> Pervasives.in_channel -> Pervasives.out_channel -> unit
copy buffer cin cout
reads cin
until end-of-file
and copy it in cout
.
buffer
is a temporary string used during the copy.
Recommended size is 2048
.
buffer
has now type bytes
instead of string
val copy : string -> string -> unit
copy source target
copies source file to target file using bincopy
.
val read_file : string -> (Pervasives.in_channel -> 'a) -> 'a
Properly close the channel and re-raise exceptions
val read_lines : string -> (string -> unit) -> unit
Iter over all text lines in the file
val write_file : string -> (Pervasives.out_channel -> 'a) -> 'a
Properly close the channel and re-raise exceptions
val print_file : string -> (Format.formatter -> 'a) -> 'a
Properly flush and close the channel and re-raise exceptions
typetimer =
float Pervasives.ref
type 'a
result =
| |
Result of |
| |
Error of |
val catch : ('a -> 'b) -> 'a -> 'b result
val return : 'a result -> 'a
val time : ?rmax:timer -> ?radd:timer -> ('a -> 'b) -> 'a -> 'b
Compute the elapsed time with Sys.time
.
The rmax
timer is maximized and the radd
timer is cumulated.
Computed result is returned, or exception is re-raised.
val full_command : string ->
string array ->
stdin:Unix.file_descr ->
stdout:Unix.file_descr -> stderr:Unix.file_descr -> Unix.process_status
Same arguments as but returns only when execution is complete.
Sys_error
when a system error occurstype
process_result =
| |
Not_ready of |
|||
| |
Result of |
(* |
| *) |
val full_command_async : string ->
string array ->
stdin:Unix.file_descr ->
stdout:Unix.file_descr ->
stderr:Unix.file_descr -> unit -> process_result
Same arguments as .
Sys_error
when a system error occursval command_async : ?stdout:Buffer.t ->
?stderr:Buffer.t -> string -> string array -> unit -> process_result
Same arguments as .
Sys_error
when a system error occursval command : ?timeout:int ->
?stdout:Buffer.t ->
?stderr:Buffer.t -> string -> string array -> Unix.process_status
Same arguments as . When this function returns, the stdout and stderr of the child process will be filled into the arguments buffer.
Sys_error
when a system error occursDb.Cancel
when the computation is interrupted or on timeout