Filename_base
Sourceinclude Ppx_compare_lib.Comparable.S with type t := t
include Base.Comparable.S
with type t := t
with type comparator_witness = Base.String.comparator_witness
include Base.Comparisons.S with type t := t
compare t1 t2
returns 0 if t1
is equal to t2
, a negative integer if t1
is less than t2
, and a positive integer if t1
is greater than t2
.
ascending
is identical to compare
. descending x y = ascending y x
. These are intended to be mnemonic when used like List.sort ~compare:ascending
and List.sort ~cmp:descending
, since they cause the list to be sorted in ascending or descending order, respectively.
clamp_exn t ~min ~max
returns t'
, the closest value to t
such that between t' ~low:min ~high:max
is true.
Raises if not (min <= max)
.
include Base.Comparator.S
with type t := t
with type comparator_witness = Base.String.comparator_witness
The path of the root.
is_posix_pathname_component f
Note that this checks a path component, and not a full path.
http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_169
The name of the temporary directory:
Under Unix, the value of the TMPDIR
environment variable, or "/tmp" if the variable is not set.
Under Windows, the value of the TEMP
environment variable, or "." if the variable is not set.
The conventional name for the current directory (e.g. .
in Unix).
The conventional name for the parent of the current directory (e.g. ..
in Unix).
The directory separator (e.g. /
in Unix).
concat p1 p2
returns a path equivalent to p1 ^ "/" ^ p2
. In the resulting path p1 (resp. p2) has all its trailing (resp. leading) "." and "/" removed. eg: concat "a/." ".//b" => "a/b" concat "." "b" => "./b" concat "a" "." => "a/." concat "a" "/b" => "a/b"
Return true
if the file name is relative to the current directory, false
if it is absolute (i.e. in Unix, starts with /
).
Return true
if the file name is relative and does not start with an explicit reference to the current directory (./
or ../
in Unix), false
if it starts with an explicit reference to the root directory or the current directory.
check_suffix name suff
returns true
if the filename name
ends with the suffix suff
.
chop_suffix name suff
removes the suffix suff
from the filename name
. The behavior is undefined if name
does not end with the suffix suff
. chop_suffix_opt
is thus recommended instead.
chop_suffix_opt ~suffix filename
removes the suffix from the filename
if possible, or returns None
if the filename does not end with the suffix.
Return the given file name without its extension. The extension is the shortest suffix starting with a period and not including a directory separator, .xyz
for instance.
Raise Invalid_argument
if the given name does not contain an extension.
split_extension fn
return the portion of the filename before the extension and the (optional) extension. Example: split_extension "/foo/my_file" = ("/foo/my_file", None) split_extension "/foo/my_file.txt" = ("/foo/my_file", Some "txt") split_extension "/home/c.falls/my_file" = ("/home/c.falls/my_file", None)
Respects the posix semantic.
Split a file name into directory name / base file name. concat (dirname name) (basename name)
returns a file name which is equivalent to name
. Moreover, after setting the current directory to dirname name
(with Sys.chdir
), references to basename name
(which is a relative file name) designate the same file as name
before the call to Sys.chdir
.
The result is not specified if the argument is not a valid file name (for example, under Unix if there is a NUL character in the string).
See Filename.basename
.
Returns the absolute path by prepending relative_to
if the path is not already absolute.
Using the result of Core_unix.getcwd
as relative_to
is often a reasonable choice.
Note that to_absolute_exn
may return a non-canonical path (e.g. /foo/bar/../baz).
Raises if relative_to
is a relative path.
Converts an absolute path to a relative one.
Raises if either argument is a relative path.
split filename
returns (dirname filename, basename filename)
parts filename
returns a list of path components in order. For instance: /tmp/foo/bar/baz -> "/"; "tmp"; "foo"; "bar"; "baz"
. The first component is always either "." for relative paths or "/" for absolute ones.
of_parts parts
joins a list of path components into a path. It does roughly the opposite of parts
, but they fail to be precisely mutually inverse because of ambiguities like multiple consecutive slashes and . components.
Raises an error if given an empty list.
Return a quoted version of a file name, suitable for use as one argument in a command line, escaping all meta-characters. Warning: under Windows, the output is only suitable for use with programs that follow the standard Windows quoting conventions.
See Sys.quote
for an alternative implementation that is more human readable but less portable.