Model of the file system
Local paths
External paths
The Path.t type
module Local_gen : sig ... endRelative path relative to the root tracked by the type system.
module Unspecified : sig ... endmodule Local : sig ... endRelative path with unspecified root.
module Source : sig ... endIn the source section of the current workspace.
module External : sig ... endmodule Build : sig ... endval hash : t -> intval to_string : t -> stringval of_string : string -> tval parse_string_exn : loc:Stdune__Loc0.t -> string -> ta directory is smaller than its descendants
include Comparator.S with type t := t
val compare : t -> t -> Ordering.tval extension : t -> stringval basename : t -> stringval basename_opt : t -> string optionmodule Set : sig ... endval to_string_maybe_quoted : t -> stringval is_root : t -> boolval hash : t -> intval to_string_maybe_quoted : t -> stringto_string_maybe_quoted t is maybe_quoted (to_string t)
val root : tval external_ : External.t -> tval is_root : t -> boolval is_managed : t -> boolval of_filename_relative_to_initial_cwd : string -> tCreate an external path. If the argument is relative, assume it is relative to the initial directory dune was launched in.
val to_absolute_filename : t -> stringConvert a path to an absolute filename. Must be called after the workspace root has been set. root is the root directory of local paths
Reach a given path from a directory. For example, let p be a path to the file some/dir/file and d be a path to the directory some/another/dir. Then reach p ~from:d evaluates to ../../dir/file.
Extract the build context from a path. For instance, representing paths as strings:
extract_build_context "_build/blah/foo/bar" = Some ("blah", "foo/bar") It doesn't work correctly (doesn't return a sensible source path) for build directories that are not build contexts, e.g. "_build/install" and "_build/.aliases".
Same as extract_build_context but return the build context as a path:
extract_build_context "_build/blah/foo/bar"
= Some ("_build/blah", "foo/bar")Drop the "_build/blah" prefix if present, return t otherwise
Drop the "_build/blah" prefix if present, return t if it's a source file, otherwise fail.
val explode : t -> string list optionval explode_exn : t -> string listval build_dir : tThe build directory
val is_in_build_dir : t -> boolis_in_build_dir t = is_descendant t ~of:build_dir
val is_in_source_tree : t -> boolis_in_source_tree t = is_managed t && not (is_in_build_dir t)
val is_strict_descendant_of_build_dir : t -> boolis_strict_descendant_of_build_dir t = is_in_build_dir t && t <> build_dir
val exists : t -> boolval readdir_unsorted : t -> (string list, Unix.error) Result.tval is_directory : t -> boolval is_file : t -> boolval rmdir : t -> unitval unlink : t -> unitval unlink_no_err : t -> unitval rm_rf : ?allow_external:bool -> t -> unitval mkdir_p : ?perms:int -> t -> unitval touch : ?create:bool -> t -> unitval in_source : string -> tpaths guaranteed to be in the source directory
val set_root : External.t -> unitSet the workspace root. Can only be called once and the path must be absolute
module L : sig ... endReturn the "local part" of a path. For local paths (in build directory or source tree), this returns the path itself. For external paths, it returns a path that is relative to the current directory. For example, the local part of /a/b is ./a/b.
val stat : t -> Unix.statsval set_of_source_paths : Source.Set.t -> Set.tval string_of_file_kind : Unix.file_kind -> stringtemp_dir prefix suffix returns the name of a fresh temporary directory in the temporary directory. The base name of the temporary directory is formed by concatenating prefix, then a suitably chosen integer number, then suffix. The optional argument temp_dir indicates the temporary directory to use, defaulting to the current result of Filename.get_temp_dir_name. The temporary directory is created with permissions mode, defaulting to 0700. The directory is guaranteed to be different from any other directory that existed when temp_dir was called.
Rename a file. rename oldpath newpath renames the file called oldpath, giving it newpath as its new name, moving it between directories if needed. If newpath already exists, its contents will be replaced with those of oldpath.
val chmod : mode:int -> ?stats:Unix.stats option -> ?op:[ `Add | `Remove | `Set ] -> t -> unitSet permissions on the designed files. op is `Set by default, which sets the permissions exactly to mode, while `Add will add the given mode to the current permissions and `Remove remove them. path will be stat'd in the `Add and `Remove case to determine the current premission, unless the already computed stats are passed as stats to save a system call.