Previous Up Next

5.8  Module Filename

Operations on file names.

val current_dir_name : 'a string
The conventional name for the current directory (e.g. . in Unix).

val parent_dir_name : 'a string
The conventional name for the parent of the current directory (e.g. .. in Unix).

val concat : 'a string -> 'a string -> 'a string
concat dir file returns a file name that designates file file in directory dir.

val is_relative : 'a string -> 'a 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_implicit : 'a string -> 'a 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 : 'a string -> 'a string -> 'a bool
check_suffix name suff returns true if the filename name ends with the suffix suff.

val chop_suffix : 'a string ->
                  'a string -{'b | Invalid_argument: 'b |}-> 'a string
                  with 'a < 'b
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.

val chop_extension : 'a string -{'b | Invalid_argument: 'b |}-> 'a string
                     with 'a < 'b
Return the given file name without its extension. The extension is the shortest suffix starting with a period, .xyz for instance.

Raise Invalid_argument if the given name does not contain a period.

val basename : 'a string -> 'a string
Split a file name into directory name / base file name.

concat (dirname name) (basename name) returns a file name which is equivalent to name.

val dirname : 'a string -> 'a string
See Filename.basename.

val quote : 'a string -> 'a string
Return a quoted version of a file name, suitable for use as one argument in a shell command line, escaping all shell meta-characters.



Previous Up Next