Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module OS.Path
Path operations.
These functions operate on files and directories equally. Similar and specific functions operating only on one kind of path can be found in the File and Dir modules.
move ~force src dst moves path src to dst. If force is true (defaults to false) the operation doesn't error if dst exists and can be replaced by src.
val delete : ?must_exist:bool ->?recurse:bool ->Fpath.t->(unit, 'e)result
delete ~must_exist ~recurse p deletes the path p. If must_exist is true (defaults to false) an error is returned if p doesn't exist. If recurse is true (defaults to false) and p is a directory, no error occurs if the directory is non-empty: its contents is recursively deleted first.
symlink ~force target p symbolically links target to dst. If force is true (defaults to false) and p exists, it is rmdired or unlinked before making the link.
symlink_stat p is the same as stat but if p is a link returns information about the link itself.
Matching path patterns against the file system
A path pattern pat is a path whose segments are made of named string patterns. Each variable of the pattern greedily matches a segment or sub-segment. For example the path pattern:
Fpath.(v "data" / "$(dir)" / "$(file).txt")
matches any existing path of the file system that matches the regexp data/.*/.*\.txt.
Warning. When segments with pattern variables are matched against the file system they never match "." and "..". For example the pattern "$(file).$(ext)" does not match ".".
matches ~dotfiles pat is the list of paths in the file system that match the path pattern pat. If dotfiles is false (default) segments that start with a pattern variable do not match dotfiles.
query ~init pat is like matches except each matching path is returned with an environment mapping pattern variables to their matched part in the path. For each path the mappings are added to init (defaults to String.Map.empty).
The type for controlling directory traversals. The predicate of `Sat should only be called with directory paths, however this may not be the case due to OS races.
During the fold, errors may be generated at different points of the process. For example, determining traversal with traverse, determining folded elements or trying to readdir(3) a directory without having permissions.
These errors are given to a function of this type. If the function returns Error _ the fold stops and returns that error. If the function returns `Ok () the path is ignored for the operation and the fold continues.
fold err dotfiles elements traverse f acc paths folds over the list of paths paths traversing directories according to traverse (defaults to `Any) and selecting elements to fold over according to elements (defaults to `Any).
If dotfiles if false (default) both elements and directories to traverse that start with a . except . and .. are skipped without being considered by elements or traverse's values.