Module Assemblage.Cmd.File

module File: sig .. end
File operations.


File operations

Note. When paths are relative they are expressed relative to the current working directory.

val exists : Assemblage.Cmd.path -> bool Assemblage.Cmd.result
exists file is true iff file exists and is not a directory.
val dev_null : Assemblage.Cmd.path
dev_null represents a file that discards all writes.

Warning. Do not use this value to define build actions, use Assemblage.Acmd.dev_null.

val delete : ?maybe:bool -> Assemblage.Cmd.path -> unit Assemblage.Cmd.result
delete ~maybe file deletes file file. If maybe is false (default) no error is returned if the file doesn't exit.
val temp : string -> Assemblage.Cmd.path Assemblage.Cmd.result
temp suffix creates a temporary file with suffix suffix and returns its name. The file is destroyed at the end of program execution.

Input


val with_inf : (Pervasives.in_channel -> 'a -> 'b Assemblage.Cmd.result) ->
Assemblage.Cmd.path -> 'a -> 'b Assemblage.Cmd.result
with_inf f inf v opens inf as a channel ic and returns f ic v if no error occurs. In case of error the channel is closed and the error is returned. If inf is Assemblage.Path.dash, ic is Pervasives.stdin and not closed.
val read : Assemblage.Cmd.path -> string Assemblage.Cmd.result
read file is file's content. If file is Assemblage.Path.dash reads from Pervasives.stdin.
val read_lines : Assemblage.Cmd.path -> string list Assemblage.Cmd.result
read_lines file is file's content splitted at '\n'. If file is Assemblage.Path.dash reads from Pervasives.stdin.

Output


val with_outf : (Pervasives.out_channel -> 'a -> 'b Assemblage.Cmd.result) ->
Assemblage.Cmd.path -> 'a -> 'b Assemblage.Cmd.result
with_inf f outf v opens outf as a channel oc and returns f oc v if no error occurs. In case of error the channel is closed and the error is returned. If outf is Assemblage.Path.dash, oc is Pervasives.stdout and not closed.
val write : Assemblage.Cmd.path -> string -> unit Assemblage.Cmd.result
write file content outputs content to file. If file is Assemblage.Path.dash, writes to Pervasives.stdout. If an error is returned file is left untouched except if Pervasives.stdout is written.
val write_lines : Assemblage.Cmd.path -> string list -> unit Assemblage.Cmd.result
write_lines file lines outputs lines separated by '\n' to file. If file is Assemblage.Path.dash, writes to Pervasives.stdout. If an error is returned file is left untouched except if Pervasives.stdout is written.
val write_subst : (string * string) list ->
Assemblage.Cmd.path -> string -> unit Assemblage.Cmd.result
write_subst vars file content outputs content to file. In content patterns of the form "%%ID%%" are replaced by the value of List.assoc "ID" vars (if any). If file is Assemblage.Path.dash, writes to Pervasives.stdout. If an error is returned file is left untouched except if Pervasives.stdout is written.

FIXME: add optional argument delim that defaults to %%, the latter may appear in programs.