1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
2001-12-07 05:41:02 -08:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
2001-10-26 15:37:14 -07:00
|
|
|
(** Operations on file names. *)
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
val current_dir_name : string
|
2001-12-03 14:01:28 -08:00
|
|
|
(** The conventional name for the current directory (e.g. [.] in Unix). *)
|
2001-10-26 15:37:14 -07:00
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val parent_dir_name : string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** The conventional name for the parent of the current directory
|
|
|
|
(e.g. [..] in Unix). *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val concat : string -> string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** [concat dir file] returns a file name that designates file
|
|
|
|
[file] in directory [dir]. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val is_relative : string -> bool
|
2001-10-26 15:37:14 -07:00
|
|
|
(** Return [true] if the file name is relative to the current
|
|
|
|
directory, [false] if it is absolute (i.e. in Unix, starts
|
|
|
|
with [/]). *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val is_implicit : string -> bool
|
2001-10-26 15:37:14 -07:00
|
|
|
(** 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. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val check_suffix : string -> string -> bool
|
2001-10-26 15:37:14 -07:00
|
|
|
(** [check_suffix name suff] returns [true] if the filename [name]
|
|
|
|
ends with the suffix [suff]. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val chop_suffix : string -> string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** [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]. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val chop_extension : string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** 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. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val basename : string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** Split a file name into directory name / base file name.
|
|
|
|
{!Filename.concat} [(]{!Filename.dirname}[ name) (]{!Filename.basename}[ name)]
|
|
|
|
returns a file name which is equivalent to [name]. Moreover, after setting the
|
|
|
|
current directory to {!Filename.dirname}[ name] (with {!Sys.chdir}),
|
|
|
|
references to {!Filename.basename}[ name] (which is a relative file name)
|
|
|
|
designate the same file as [name] before the call to {!Sys.chdir}. *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
val dirname : string -> string
|
2001-12-03 14:01:28 -08:00
|
|
|
(** See {!Filename.dirname}. *)
|
2001-10-26 15:37:14 -07:00
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val temp_file : string -> string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** [temp_file prefix suffix] returns the name of a
|
|
|
|
fresh temporary file in the temporary directory.
|
|
|
|
The base name of the temporary file is formed by concatenating
|
|
|
|
[prefix], then a suitably chosen integer number, then [suffix].
|
|
|
|
The temporary file is created empty, and is guaranteed to be
|
|
|
|
different from any other file that existed when [temp_file]
|
|
|
|
was called.
|
|
|
|
Under Unix, the temporary directory is [/tmp] by default; if set,
|
|
|
|
the value of the environment variable [TMPDIR] is used instead.
|
|
|
|
Under Windows, the name of the temporary directory is the
|
|
|
|
value of the environment variable [TEMP],
|
|
|
|
or [C:\temp] by default.
|
|
|
|
Under MacOS, the name of the temporary directory is given
|
|
|
|
by the environment variable [TempFolder]; if not set,
|
|
|
|
temporary files are created in the current directory. *)
|
|
|
|
|
2001-12-03 14:01:28 -08:00
|
|
|
val quote : string -> string
|
2001-10-26 15:37:14 -07:00
|
|
|
(** Return a quoted version of a file name, suitable for use as
|
|
|
|
one argument in a shell command line, escaping any shell
|
|
|
|
meta-characters. *)
|
|
|
|
|