Famous file paths
val null :
null represents a file on the OS that discards all writes
and returns end of file on reads.
val dash :
Existence and deletion
val exists :
Topkg.fpath -> bool Topkg.result
exists file is
file is a regular in the file
system and false otherwise. Symbolic links are followed.
val must_exist :
Topkg.fpath -> Topkg.fpath Topkg.result
must_exist file is
file is a regular file in the
file system and an error otherwise. Symbolic links are followed.
val delete :
?must_exist:bool -> Topkg.fpath -> unit Topkg.result
delete ~must_exist file deletes file
true (defaults to
false) an error is returned if
Folding over file hierarchies
val fold :
?skip:(Topkg.fpath -> bool) ->
(Topkg.fpath -> 'a -> 'a) -> 'a -> Topkg.fpath list -> 'a Topkg.result
fold_files skip f acc paths folds
f over the files
found in the file hierarchies starting at
p for which
skip p is
true are skipped.
skip defaults to
(fun _ -> false).
Reading and writing
val read :
Topkg.fpath -> string Topkg.result
's contents. If
and the channel is not closed when
the function returns.
val write :
Topkg.fpath -> string -> unit Topkg.result
write file content
and flushes but doesn't close the channel
when the function returns.
val write_subst :
Topkg.fpath -> (string * string) list -> string -> unit Topkg.result
write_subst file vars content
except any occurence
of a string of the form
is replaced by the
List.assoc "ID" vars
, if any.
val tmp :
unit -> Topkg.fpath Topkg.result
tmp () creates a temporary file and returns its name. The file
is destroyed at the end of program execution.