Module B0.OS.Dir

module Dir: sig .. end
Directory operations.


Existence, creation, deletion and contents


val exists : B0.Fpath.t -> bool B0.result
exists dir is true if dir is a directory in the file system and false otherwise. Symbolic links are followed.
val must_exist : B0.Fpath.t -> B0.Fpath.t B0.result
must_exist dir is Ok dir if dir is a directory in the file system and an error otherwise. Symbolic links are followed.
val create : ?path:bool -> ?mode:int -> B0.Fpath.t -> bool B0.result
create ~path ~mode dir creates, if needed, the directory dir with file permission mode (defaults 0o755 readable and traversable by everyone, writeable by the user). If path is true (default) intermediate directories are created with the same mode, otherwise missing intermediate directories lead to an error. The result is false if dir already exists. Note. The mode of existing directories, including dir if this is the case is kept unchanged.
val delete : ?must_exist:bool -> contents:bool -> B0.Fpath.t -> unit B0.result
delete ~must_exist ~contents dir deletes the directory dir. If contents is true no error occurs if the directory is non-empty: its contents is recursively deleted first. If must_exist is true (defaults to false) an error is returned if dir doesn't exist.
val contents : ?dotfiles:bool -> ?rel:bool -> B0.Fpath.t -> B0.Fpath.t list B0.result
contents ~dotfiles ~rel dir is the list of directories and files in dir. If rel is false (default) the resulting path have dir prepended, if true they are relative to dir. If dotfiles is false (default) elements that start with a . are omitted.
val files : ?dotfiles:bool -> ?rel:bool -> B0.Fpath.t -> B0.Fpath.t list B0.result
files is like B0.OS.Dir.contents but only returns files.
val dirs : ?dotfiles:bool -> ?rel:bool -> B0.Fpath.t -> B0.Fpath.t list B0.result
dirs is like B0.OS.Dir.contents but only returns directories.

Current working directory


val current : unit -> B0.Fpath.t B0.result
current () is the current working directory. The resulting path is guaranteed to be absolute.
val set_current : B0.Fpath.t -> unit B0.result
set_current dir sets the current working directory to dir.
val with_current : B0.Fpath.t -> ('a -> 'b) -> 'a -> 'b B0.result
with_current dir f v is f v with the current working directory bound to dir. After the function returns the current working directory is back to its initial value.

Default Temporary directory


val default_tmp : unit -> B0.Fpath.t
default_tmp () is the directory used as a default value for creating temporary files and directories. If B0.OS.Dir.set_default_tmp hasn't been called this is:
val set_default_tmp : B0.Fpath.t -> unit
set_default_tmp p sets the value returned by B0.OS.Dir.default_tmp to p.