Module Make.FileSource

Sourceval exists : blk Mfat.t -> Fpath.t -> (bool, 'err) result

exists t file is true if file is a regular file in the file system and false otherwise.

Sourceval must_exist : blk Mfat.t -> Fpath.t -> (Fpath.t, [> `Msg of string ]) result

must_exist t file is Ok file if file is a regular file in the file system and an error otherwise.

Sourceval delete : blk Mfat.t -> ?must_exist:bool -> Fpath.t -> (unit, [> `Msg of string ]) result

delete t ~must_exist file deletes file file. If must_exist is true (defaults to false) an error is returned if file doesn't exist.

Sourceval read : blk Mfat.t -> Fpath.t -> (string, [> `Msg of string ]) result

read t file is file's content as a string.

Sourceval read_lines : blk Mfat.t -> Fpath.t -> (string list, [> `Msg of string ]) result

read_lines t file is file's content, split at each '\n' character.

Sourceval fold_lines : (string -> 'a -> 'a) -> 'a -> blk Mfat.t -> Fpath.t -> ('a, [> `Msg of string ]) result

fold_lines f acc t file is like List.fold_left f acc (read_lines t file).

Sourceval write : blk Mfat.t -> Fpath.t -> string -> (unit, [> `Msg of string ]) result

write t file content outputs content to file.

Sourceval write_lines : blk Mfat.t -> Fpath.t -> string list -> (unit, [> `Msg of string ]) result

write_lines t file lines writes lines joined by "\n" to file.