package dune
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=77cb5f483221b266ded2b85fc84173ae0089a25134a086be922e82c131456ce6
sha512=02f00fd872aa49b832fc8c1e928409f23c79ddf84a53009a58875f222cca36fbb92c905e12c539caec9cbad723f195a8aa24218382dca35a903b3f52b11f06f2
doc/dune._stdune/Stdune/Path/index.html
Module Stdune.Path
Representation of paths
The aim of this module is to provide a solid basis to reason about file and directory paths inside the Dune code base. What it is not is a complete API for paths management that handles all the aspects of file system paths. It simply exposes a high-level and portable API that covers the needs of Dune.
Model of the file system
Local paths
Dune sees the file system as two parts. The first part is composed of the source tree and the build directory. In this part, Dune doesn't know about symlinks and has a fully expanded view of the file system. This means that if the user has a symlink `src/foo` pointing to `bar`, then `src/foo/x` and `bar/x` are seen as two different paths.
A path in this world is called a local path and is simply a sequence of path components. A path component being a string other than "." or ".." and not containing the path separator character ('/').
Such a path can be rooted at the source tree root, the build directory or an unspecified root. All these paths are represented by values of type 'a Path.Local_gen.t
where 'a
denotes the root of the path.
External paths
The second part is the "external world". It is all the paths that live outside of the workspace and build directory. To be on the safe side Dune makes no assumption does nothing clever with these paths.
External paths are presented as Path.External.t
values.contents
The Path.t type
The Path.t
type represents all possible paths, i.e. both local and extenral paths.
module Local_gen : sig ... end
Relative path relative to the root tracked by the type system.
module Unspecified : sig ... end
module Local : sig ... end
Relative path with unspecified root.
module Source : sig ... end
In the source section of the current workspace.
module External : sig ... end
module Build : sig ... end
val to_string : t -> string
val of_string : string -> t
val parse_string_exn : loc:Stdune__.Loc0.t -> string -> t
val pp : Format.formatter -> t -> unit
a directory is smaller than its descendants
include Comparator.S with type t := t
val compare : t -> t -> Ordering.t
val extension : t -> string
val basename : t -> string
module Set : sig ... end
val hash : t -> int
val to_string_maybe_quoted : t -> string
to_string_maybe_quoted t
is maybe_quoted (to_string t)
val root : t
val external_ : External.t -> t
val is_root : t -> bool
val is_managed : t -> bool
val of_filename_relative_to_initial_cwd : string -> t
Create 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 -> string
Convert a path to an absolute filename. Must be called after the workspace root has been set. root
is the root directory of local paths
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 option
val explode_exn : t -> string list
val build_dir : t
The build directory
val is_in_build_dir : t -> bool
is_in_build_dir t = is_descendant t ~of:build_dir
val is_in_source_tree : t -> bool
is_in_build_dir t = is_managed t && not (is_in_build_dir t)
val is_strict_descendant_of_build_dir : t -> bool
is_strict_descendant_of_build_dir t = is_in_build_dir t && t <> build_dir
val exists : t -> bool
val readdir_unsorted : t -> (string list, Unix.error) Result.t
val is_directory : t -> bool
val is_file : t -> bool
val rmdir : t -> unit
val unlink : t -> unit
val unlink_no_err : t -> unit
val rm_rf : t -> unit
val mkdir_p : t -> unit
val pp_debug : Format.formatter -> t -> unit
val in_source : string -> t
paths guaranteed to be in the source directory
val set_root : External.t -> unit
Set the workspace root. Can only be called once and the path must be absolute
module L : sig ... end
Return 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.stats
val set_of_source_paths : Source.Set.t -> Set.t