module Filepath: sig
.. end
Functions manipulating filepaths.
In these functions, references to the present working directory refer
to the result given by function Sys.getcwd.
val normalize : ?base:string -> string -> string
Returns an absolute path leading to the given file.
The result is similar to
realpath --no-symlinks
.
Some special behaviors include:
normalize ""
(empty string) raises Invalid_argument
(realpath returns an error);
normalize
preserves multiple sequential '/' characters,
unlike realpath
;
- non-existing directories in
realpath
may lead to ENOTDIR errors,
but normalize
may accept them.
Change in Aluminium-20160501: optional base.
val relativize : ?base:string -> string -> string
relativize base file
returns a (strict) relative path of file
w.r.t. base
, if base
is a prefix of file
; otherwise,
returns file
unchanged.
The default base is the present working directory.
Since Aluminium-20160501
val is_relative : ?base:string -> string -> bool
returns true if the file is strictly relative to base
(that is, it is prefixed by base
), or to the present working directory
if no base is specified.
Since Aluminium-20160501
val pretty : string -> string
Pretty-print a path according to these rules:
- relative filenames are kept, except for leading './', which are stripped;
- absolute filenames are relativized if their prefix is included in the
present working directory; also, symbolic names are resolved,
i.e. the result may be prefixed by known aliases (e.g. FRAMAC_SHARE).
See
Filepath.add_symbolic_dir
for more details.
Therefore, the result of this function may not designate a valid name
in the filesystem.
Since Neon-20140301
val add_symbolic_dir : string -> string -> unit
add_symbolic_dir name dir
indicates that the (absolute) path dir
must
be replaced by name
when pretty-printing paths.
This alias ensures that system-dependent paths such as FRAMAC_SHARE are
printed identically in different machines.