val with_open_r : FS.t -> Fpath.t -> ([ `Read ] FS.File.fd -> ('a, [> `Open of Fpath.t * FS.error | `Move of Fpath.t * Fpath.t * FS.error ] as 'e) Stdlib.result Lwt.t) -> ('a, 'e) Stdlib.result Lwt.t
with_open_r t p f
opens the file p
in the file-system t
with read-only mode and calls f
on the resulting file-descriptor. When f
completes, the file-descriptor is closed. Failure to close that file-descriptor is ignored.
val with_open_w : ?atomic:bool -> FS.t -> temp_dir:Fpath.t -> Fpath.t -> ([ `Write ] FS.File.fd -> ('a, [> `Open of Fpath.t * FS.error | `Move of Fpath.t * Fpath.t * FS.error ] as 'e) Stdlib.result Lwt.t) -> ('a, 'e) Stdlib.result Lwt.t
Same as with_open_r
but the file p
is opened in read-write mode. If atomic
is set (it is by default), the application of f
is guaranteed to be atomic. This is done by creating a temporary file and renaming it when all the work is done.