package lsp
Install
Dune Dependency
Authors
-
AAndrey Popp <8mayday@gmail.com>
-
RRusty Key <iam@stfoo.ru>
-
LLouis Roché <louis@louisroche.net>
-
OOleksiy Golovko <alexei.golovko@gmail.com>
-
RRudi Grinberg <me@rgrinberg.com>
-
SSacha Ayoun <sachaayoun@gmail.com>
-
Ccannorin <cannorin@gmail.com>
-
UUlugbek Abdullaev <ulugbekna@gmail.com>
-
Thibaut Mattio
-
MMax Lantas <mnxndev@outlook.com>
Maintainers
Sources
sha256=90ac8fc3b291bc9c28b93d39fee6c75615f278f70ad795912fa5a47fa1a08c89
sha512=9460328d2559d86e9d56bcf8a9ef722c57d20a53c41e47398c36401bdc13dd9874e885586f2ad2d0492707bc3a5e7d5393afcebe1cbad1c15fb314884502bd1d
doc/lsp.stdune/Stdune/Path/index.html
Module Stdune.Path
Source
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 represented as Path.External.t
values.
The Path.t type
The Path.t
type represents all possible paths, i.e. both local and external paths.
type t = private
| External of External.t
| In_source_tree of Source.t
| In_build_dir of Build.t
a directory is smaller than its descendants
include Comparator.S with type t := t
set_extension path ~ext
replaces extension of path
by ext
to_string_maybe_quoted t
is maybe_quoted (to_string t)
Create an external path. If the argument is relative, assume it is relative to the initial directory dune was launched in.
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
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.
is_in_source_tree t = is_managed t && not (is_in_build_dir t)
is_strict_descendant_of_build_dir t = is_in_build_dir t && t <> build_dir
Split after the first component if t
is local
If the path does not exist, this function is a no-op.
clear_dir t
deletes all the contents of directory t
without removing t
itself.
Set the workspace root. Can only be called once and the path must be absolute
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
.
Rename a file. rename oldpath newpath
renames the file called oldpath
to newpath
, moving it between directories if needed. If newpath
already exists, its contents will be replaced with those of oldpath
.
Set permissions for a given path. You can use the Permissions
module if you need to modify existing permissions in a non-trivial way.
Attempts to resolve a symlink. Returns None
if the path isn't a symlink