module FilePath:sig..end
Operations on abstract filenames.
This module allow to manipulate string or abstract representation of a filename.
Abstract representation of a filename allow to decode it only once, and should speed up further operation on it (comparison in particular). If you intend to do a lot of processing on filename, you should consider using its abstract representation.
This module manipulate abstract path that are not bound to a real
filesystem. In particular, it makes the assumption that there is no
symbolic link that should modify the meaning of a path. If you intend to use
this module against a real set of filename, the best solution is to apply to
every filename to solve symbolic link through FileUtil.readlink.
typefilename =string
Filename type.
typeextension =string
Extension type.
exception BaseFilenameRelative of filename
Cannot pass a base filename which is relative.
exception UnrecognizedOS of string
We do not have recognized any OS, please contact upstream.
exception EmptyFilename
The filename use was empty.
exception NoExtension of filename
The last component of the filename does not support extension (Root, ParentDir...)
exception InvalidFilename of filename
The filename used is invalid.
val is_subdir : filename -> filename -> boolis_subdir fl1 fl2 Is fl2 a sub directory of fl1
val is_updir : filename -> filename -> boolis_updir fl1 fl2 Is fl1 a sub directory of fl2
val compare : filename -> filename -> intcompare fl1 fl2 Give an order between the two filename. The
classification is done by sub directory relation, fl1 < fl2 iff fl1 is
a subdirectory of fl2, and lexicographical order of each part of the
reduce filename when fl1 and fl2 has no hierarchical relation
val current_dir : filenameCurrent dir.
val parent_dir : filenameUpper dir.
val make_filename : string list -> filenameMake a filename from a set of strings.
val basename : filename -> filenameExtract only the file name of a filename.
val dirname : filename -> filenameExtract the directory name of a filename.
val concat : filename -> filename -> filenameAppend a filename to a filename.
val reduce : ?no_symlink:bool -> filename -> filenameReturn the shortest filename which is equal to the filename given. It remove
the "." in Unix filename, for example.
If no_symlink flag is set, consider that the path doesn't contain symlink
and in this case ".." for Unix filename are also reduced.
val make_absolute : filename -> filename -> filenameCreate an absolute filename from a filename relative and an absolute base filename.
val make_relative : filename -> filename -> filenameCreate a filename which is relative to the base filename.
val reparent : filename ->
filename -> filename -> filenamereparent fln_src fln_dst fln Return the same filename as fln
but the root is no more fln_src but fln_dst. It replaces the
fln_src prefix by fln_dst.
val identity : filename -> filenameIdentity for testing the stability of implode/explode.
val is_valid : filename -> boolTest if the filename is a valid one.
val is_relative : filename -> boolCheck if the filename is relative to a dir or not.
val is_current : filename -> boolCheck if the filename is the current directory.
val is_parent : filename -> boolCheck if the filename is the parent directory.
Extension is define as the suffix of a filename, just after the last ".".
val chop_extension : filename -> filenameRemove extension and the trailing ".".
val get_extension : filename -> extensionExtract the extension.
val check_extension : filename -> extension -> boolCheck the extension.
val add_extension : filename -> extension -> filenameAdd an extension with a "." before.
val replace_extension : filename -> extension -> filenameReplace extension.
PATH-like refers the environment variable PATH. This variable holds a list
of filename. The functions string_of_path and path_of_string allow to
convert this kind of list by using the good separator between filename.
val string_of_path : filename list -> stringCreate a PATH-like string.
val path_of_string : string -> filename listExtract filenames from a PATH-like string.
Definition of operations for path manipulation.
module type PATH_SPECIFICATION =sig..end
Generic operations.
module type PATH_STRING_SPECIFICATION =sig..end
Generic operations, with type filename and extension as strings.
Operations on filenames for other OS. The FilePath.DefaultPath always match the
current OS.
module DefaultPath:PATH_STRING_SPECIFICATION
Default operating system.
module UnixPath:PATH_STRING_SPECIFICATION
Unix operating system.
module MacOSPath:PATH_STRING_SPECIFICATION
MacOS operating system.
module Win32Path:PATH_STRING_SPECIFICATION
Win32 operating system.
module CygwinPath:PATH_STRING_SPECIFICATION
Cygwin operating system.