Legend:
Library
Module
Module type
Parameter
Class
Class type
Accessing paths on a file-system.
A _ Path.t represents a particular location in some filesystem. It is a pair of a base directory and a relative path from there.
Eio.Stdenv.cwd provides access to the current working directory. For example:
let ( / ) = Eio.Path.( / )
let run dir =
Eio.Path.save ~create:(`Exclusive 0o600)
(dir / "output.txt") "the data"
let () =
Eio_main.run @@ fun env ->
run (Eio.Stdenv.cwd env)
It is normally not permitted to access anything above the base directory, even by following a symlink. The exception is Stdenv.fs, which provides access to the whole file-system:
Eio.Path.load (fs / "/etc/passwd")
In Eio, the directory separator is always "/", even on Windows. Use native to convert to a native path.
native t returns a path that can be used to refer to t with the host platform's native string-based file-system APIs, if available. This is intended for interoperability with non-Eio libraries.
This does not check for confinement (the resulting path might not be accessible via t itself). Also, if a directory was opened with open_dir and later renamed, this might use the old name.
Using strings as paths is not secure if components in the path can be replaced by symlinks while the path is being used. For example, if you try to write to "/home/mal/output.txt" just as mal replaces "output.txt" with a symlink to "/etc/passwd".
with_open_in is like open_in, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).
val with_lines : _t->(string Stdlib.Seq.t->'a)->'a
with_lines t fn is a convenience function for streaming the lines of the file.
with_open_out is like open_out, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).
This can be passed to functions to grant access only to the subtree t.
val with_open_dir : _t->([< `Close | Fs.dir_ty ]t->'a)->'a
with_open_dir is like open_dir, but calls fn dir with the new directory and closes it automatically when fn returns (if it hasn't already been closed by then).
rmtree t removes t (and its contents, recursively, if it's a directory).
parametermissing_ok
If false (the default), raise an Fs.error.Not_found IO error if t doesn't exist. If true, ignore missing items. This applies recursively, allowing two processes to attempt to remove a tree at the same time.