package metadb

  1. Overview
  2. Docs

Module Metadb.PathSource

A minimal library for manipulating typed representations of paths

Sourceexception InvalidRootType of string
Sourceexception InvalidRelType of string
Sourceexception InvalidNameType of string
Sourcetype root

A root path has the form "/some/.../path"

Sourcetype rel

A relative path has the form "some/.../path"

Sourcetype name

A name is the name of a file or directory, which cannot contain the character '/'

Sourceval debug : bool ref

Debugging mode. Debugging mode is set to false by default.

Sourceval mk_root : string -> root

Constructor for creating a root path, if debug is set to true, mk_root will check that input is well-formed. Raise InvalidRootType otherwise

Sourceval mk_rel : string -> rel

Constructor for creating a relative path, if debug is set to true, mk_rel will check that input is well-formed. Raise InvalidRelType otherwise

Sourceval mk_name : string -> name

Constructor for creating a name, if debug is set to true, mk_name will check that input is well-formed. Raise InvalidNameType otherwise

Sourceval string_of_root : root -> string

Convert a root path to a string

Sourceval string_of_rel : rel -> string

Convert a relative path to a string

Sourceval string_of_name : name -> string

Convert a name to a string

Sourceval split : rel -> name list

split path splits a relative path into a list of names

Sourceval merge : root -> rel -> root

merge root path produces the path root'/'path

Sourceval merge_lst : root -> name list -> root

merge root names is the same as merge but a relative path is given as a list of names

Sourceval unroot : root -> root * rel

unroot "/some/.../path" will return ("/", "some/.../path")

Sourceval add_file_ext : string -> root -> root

add_file_ext ext path wiil add the file extension ext to the leaf of path, that is path'.'ext

Sourceval remove_file_ext : string -> root -> root

remove_file_ext ext path removes the file extension from the file name

Sourceval remove_file_ext_rel : string -> rel -> rel

Same as remove_file_ext, but for relative paths

Sourceval strip_root : root -> root -> rel

strip_root root path will drop the initial substring root from path, thus inversing merge

Sourceval get_leaf : root -> name

get_leaf "/some/.../path/leaf" returns the leaf of a path, that is leaf

Sourceval get_leaf_rel : rel -> name

Same as get_leaf but for relative paths

Sourceval drop_leaf : root -> root

drop_leaf "/some/.../path/leaf" will return "/some/.../path"

Sourceval hidden : root -> bool

hidden path will return true if the leaf of path is a hidden file, that is starts with '.'

Sourceval pp_root : Format.formatter -> root -> unit

Pretty print path

Sourceval pp_rel : Format.formatter -> rel -> unit
OCaml

Innovation. Community. Security.