module UtilsFilepath: Filepath
val normalize : ?base_name: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) returns ""
(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_name.
val relativize : ?base_name:string -> string -> string
relativize base_name file_name
returns a relative path name of
file_name
w.r.t. base_name
, if base_name
is a prefix of file
;
otherwise, returns file_name
unchanged.
The default base name is the current working directory name.
Since Aluminium-20160501
val is_relative : ?base_name:string -> string -> bool
returns true if the file is relative to base
(that is, it is prefixed by base_name
), or to the current working directory
if no base is specified.
Since Aluminium-20160501
val pretty : string -> string
Deprecated.since 18.0-Argon
DEPRECATED: use
Normalized.to_pretty_string
instead.
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
current 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.
module Normalized: sig
.. end
The Normalized
module is simply a wrapper that ensures that paths are
always normalized.
type
position = {
|
pos_path : Normalized.t ; |
|
pos_lnum : int ; |
|
pos_bol : int ; |
|
pos_cnum : int ; |
}
Describes a position in a source file.
Since 18.0-Argon
val pp_pos : Format.formatter -> position -> unit
Pretty-prints a position, in the format file:line.
Since 18.0-Argon