module File: sig
.. end
File IO.
val cut_ext : Omod.fpath -> string * string
cut_ext f
is (fst, snd)
the pair that results from cutting
the basename of f
at the rightmost '.'
(not included in the
result) before the first Filename.dir_sep
. If there is no such
character, fst is f
and snd
is ""
.
val catch_sys_error : (unit -> ('a, string) Pervasives.result) -> ('a, string) Pervasives.result
catch_sys_error f
invokes f ()
and catches any Sys_error
that
may be raised and returns its message e
as Error e
.
val with_open_in : string -> (Pervasives.in_channel -> 'a) -> ('a, string) Pervasives.result
with_open_in file f
open a channel on file
and gives it
to f
. Ensures the channel is closed when the function returns
and reports any Sys_error
or End_of_file
as an Error
.
val with_open_out : string -> (Pervasives.out_channel -> 'a) -> ('a, string) Pervasives.result
with_open_out file f
open a channel on file
and gives it
to f
. Ensures the channel is closed when the function returns
and reports any Sys_error
or End_of_file
as an Error
.
val to_string : Omod.fpath -> (string, string) Pervasives.result
to_string file
reads file file
to a string.
val of_string : Omod.fpath -> string -> (unit, string) Pervasives.result
of_string file s
writes file file
with s
.
val exists : Omod.fpath -> (bool, string) Pervasives.result
exists file
is true
iff file
exists and is not a directory.
val delete : Omod.fpath -> (bool, string) Pervasives.result
delete file
deletes file file
. The boolean indicates
whether the file actually existed.