package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of Filename_base
type t = Base.string
include Ppx_compare_lib.Comparable.S with type t := t
include Ppx_hash_lib.Hashable.S with type t := t
include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val t_sexp_grammar : t Sexplib0.Sexp_grammar.t
include Base.Comparable.S with type t := t with type comparator_witness = Base.String.comparator_witness
type comparator_witness = Base.String.comparator_witness
val root : Base.string

The path of the root.

Pathname resolution

val is_posix_pathname_component : Base.string -> Base.bool

is_posix_pathname_component f

  • returns

    true if f is a valid path component on a POSIX compliant OS

    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

val temp_dir_name : Base.string

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.

val current_dir_name : Base.string

The conventional name for the current directory (e.g. . in Unix).

val parent_dir_name : Base.string

The conventional name for the parent of the current directory (e.g. .. in Unix).

val dir_sep : Base.string

The directory separator (e.g. / in Unix).

val concat : Base.string -> Base.string -> Base.string

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"

@throws Failure if p1 is empty.

val is_relative : Base.string -> Base.bool

Return true if the file name is relative to the current directory, false if it is absolute (i.e. in Unix, starts with /).

val is_absolute : Base.string -> Base.bool
val is_implicit : Base.string -> Base.bool

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.

val check_suffix : Base.string -> Base.string -> Base.bool

check_suffix name suff returns true if the filename name ends with the suffix suff.

val chop_suffix : Base.string -> Base.string -> Base.string

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.

val chop_suffix_opt : suffix:Base.string -> Base.string -> Base.string Base.option

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.

val chop_extension : Base.string -> Base.string

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.

val split_extension : Base.string -> Base.string * Base.string Base.option

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)

val basename : Base.string -> Base.string

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).

val dirname : Base.string -> Base.string
val to_absolute_exn : Base.string -> relative_to:Base.string -> Base.string

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.

val of_absolute_exn : Base.string -> relative_to:Base.string -> Base.string

Converts an absolute path to a relative one.

Raises if either argument is a relative path.

val split : Base.string -> Base.string * Base.string

split filename returns (dirname filename, basename filename)

val parts : Base.string -> Base.string Base.list

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.

val of_parts : Base.string Base.list -> Base.string

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.

val quote : Base.string -> Base.string

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.

val arg_type : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val create_arg_type : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val open_temp_file : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val open_temp_file_fd : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val realpath : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val temp_dir : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val temp_file : [ `Use_Filename_unix ]
  • deprecated [since 2021-04] Use [Filename_unix]
val bin_size_t : t Bin_prot__.Size.sizer
val bin_write_t : t Bin_prot__.Write.writer
val bin_read_t : t Bin_prot__.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot__.Read.reader
val bin_shape_t : Bin_prot__.Shape.t
val bin_writer_t : t Bin_prot__.Type_class.writer
val bin_reader_t : t Bin_prot__.Type_class.reader
val bin_t : t Bin_prot__.Type_class.t
include Comparable.S with type t := t and type comparator_witness := comparator_witness
include Base.Comparable.S with type t := t with type comparator_witness := comparator_witness
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val equal : t -> t -> bool
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
val comparator : (t, comparator_witness) Base__Comparator.comparator
val validate_lbound : min:t Maybe_bound.t -> t Validate.check
val validate_ubound : max:t Maybe_bound.t -> t Validate.check
val validate_bound : min:t Maybe_bound.t -> max:t Maybe_bound.t -> t Validate.check
module Replace_polymorphic_compare : sig ... end
module Map : Map.S with type Key.t = t with type Key.comparator_witness = comparator_witness
module Set : Set.S with type Elt.t = t with type Elt.comparator_witness = comparator_witness
include Hashable.S with type t := t
include Ppx_compare_lib.Comparable.S with type t := t
val compare : t Base__Ppx_compare_lib.compare
include Ppx_hash_lib.Hashable.S with type t := t
val hash_fold_t : t Base__Ppx_hash_lib.hash_fold
val hash : t -> Base__Ppx_hash_lib.Std.Hash.hash_value
val hashable : t Core__.Hashtbl.Hashable.t
module Table : Hashtbl.S with type key = t
module Hash_set : Hash_set.S with type elt = t
module Hash_queue : Hash_queue.S with type key = t
module Stable : sig ... end
OCaml

Innovation. Community. Security.