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 *)
|
|
|
|
(* under the terms of the GNU Library General Public License. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-08-09 06:15:01 -07:00
|
|
|
(* Module [Filename]: operations on file names *)
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
val current_dir_name : string
|
|
|
|
(* The conventional name for the current directory
|
|
|
|
(e.g. [.] in Unix). *)
|
1999-12-30 04:54:15 -08:00
|
|
|
val parent_dir_name : string
|
|
|
|
(* The conventional name for the parent of the current directory
|
|
|
|
(e.g. [..] in Unix). *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val concat : string -> string -> string
|
|
|
|
(* [concat dir file] returns a file name that designates file
|
|
|
|
[file] in directory [dir]. *)
|
1997-06-16 10:07:42 -07:00
|
|
|
val is_relative : string -> 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 : string -> 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. *)
|
2000-04-02 18:57:52 -07:00
|
|
|
val check_suffix : string -> string -> bool
|
1995-05-04 03:15:53 -07:00
|
|
|
(* [check_suffix name suff] returns [true] if the filename [name]
|
|
|
|
ends with the suffix [suff]. *)
|
2000-04-02 18:57:52 -07:00
|
|
|
val chop_suffix : string -> string -> string
|
2000-01-07 08:47:25 -08:00
|
|
|
(* [chop_suffix name suff] removes the suffix [suff] from
|
1995-05-04 03:15:53 -07:00
|
|
|
the filename [name]. The behavior is undefined if [name] does not
|
|
|
|
end with the suffix [suff]. *)
|
1995-10-24 08:38:03 -07:00
|
|
|
val chop_extension : string -> string
|
1997-06-19 08:00:14 -07:00
|
|
|
(* Return the given file name without its extension. The extension
|
|
|
|
is the shortest suffix starting with a period, [.xyz] for instance.
|
1995-10-24 08:38:03 -07:00
|
|
|
Raise [Invalid_argument] if the given name does not contain
|
|
|
|
a period. *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val basename : string -> string
|
|
|
|
val dirname : string -> 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]. Moreover, after setting the
|
1995-08-09 02:39:43 -07:00
|
|
|
current directory to [dirname name] (with [Sys.chdir]),
|
1995-05-04 03:15:53 -07:00
|
|
|
references to [basename name] (which is a relative file name)
|
1998-04-27 02:55:50 -07:00
|
|
|
designate the same file as [name] before the call to [Sys.chdir]. *)
|
2000-01-07 08:47:25 -08:00
|
|
|
val temp_file : prefix:string -> suffix:string -> string
|
1996-01-04 04:50:37 -08:00
|
|
|
(* [temp_file prefix suffix] returns the name of a
|
2001-03-29 05:13:26 -08:00
|
|
|
fresh temporary file in the temporary directory.
|
1996-01-04 04:50:37 -08:00
|
|
|
The base name of the temporary file is formed by concatenating
|
1997-10-24 08:54:07 -07:00
|
|
|
[prefix], then a suitably chosen integer number, then [suffix].
|
2001-03-29 05:13:26 -08:00
|
|
|
The temporary file is created empty, and is guaranteed to be
|
|
|
|
different from any other file that existed when [temp_file]
|
|
|
|
was called.
|
1997-10-24 08:54:07 -07:00
|
|
|
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],
|
1998-04-27 02:55:50 -07:00
|
|
|
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. *)
|
2000-01-07 08:47:25 -08:00
|
|
|
val quote : string -> string;;
|
1999-11-29 11:04:04 -08:00
|
|
|
(* Return a quoted version of a file name, suitable for use as
|
2000-01-07 08:47:25 -08:00
|
|
|
one argument in a shell command line, escaping any shell
|
|
|
|
meta-characters. *)
|