.TH "Filename" 3o source: 2016-12-21 OCamldoc "OCaml library" .SH NAME Filename \- Operations on file names. .SH Module Module Filename .SH Documentation .sp Module .BI "Filename" : .B sig end .sp Operations on file names\&. .sp .sp .sp .I val current_dir_name : .B string .sp The conventional name for the current directory (e\&.g\&. .B \&. in Unix)\&. .sp .I val parent_dir_name : .B string .sp The conventional name for the parent of the current directory (e\&.g\&. .B \&.\&. in Unix)\&. .sp .I val dir_sep : .B string .sp The directory separator (e\&.g\&. .B / in Unix)\&. .sp .B "Since" 3.11.2 .sp .I val concat : .B string -> string -> string .sp .B concat dir file returns a file name that designates file .B file in directory .B dir \&. .sp .I val is_relative : .B string -> bool .sp Return .B true if the file name is relative to the current directory, .B false if it is absolute (i\&.e\&. in Unix, starts with .B / )\&. .sp .I val is_implicit : .B string -> bool .sp Return .B true if the file name is relative and does not start with an explicit reference to the current directory ( .B \&./ or .B \&.\&./ in Unix), .B false if it starts with an explicit reference to the root directory or the current directory\&. .sp .I val check_suffix : .B string -> string -> bool .sp .B check_suffix name suff returns .B true if the filename .B name ends with the suffix .B suff \&. .sp .I val chop_suffix : .B string -> string -> string .sp .B chop_suffix name suff removes the suffix .B suff from the filename .B name \&. The behavior is undefined if .B name does not end with the suffix .B suff \&. .sp .I val chop_extension : .B string -> string .sp Return the given file name without its extension\&. The extension is the shortest suffix starting with a period and not including a directory separator, .B \&.xyz for instance\&. .sp Raise .B Invalid_argument if the given name does not contain an extension\&. .sp .I val basename : .B string -> string .sp Split a file name into directory name / base file name\&. If .B name is a valid file name, then .B concat (dirname name) (basename name) returns a file name which is equivalent to .B name \&. Moreover, after setting the current directory to .B dirname name (with .B Sys\&.chdir ), references to .B basename name (which is a relative file name) designate the same file as .B name before the call to .B Sys\&.chdir \&. .sp This function conforms to the specification of POSIX\&.1\-2008 for the .B basename utility\&. .sp .I val dirname : .B string -> string .sp See .B Filename\&.basename \&. This function conforms to the specification of POSIX\&.1\-2008 for the .B dirname utility\&. .sp .I val temp_file : .B ?temp_dir:string -> string -> string -> string .sp .B 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 .B prefix , then a suitably chosen integer number, then .B suffix \&. The optional argument .B temp_dir indicates the temporary directory to use, defaulting to the current result of .B Filename\&.get_temp_dir_name \&. The temporary file is created empty, with permissions .B 0o600 (readable and writable only by the file owner)\&. The file is guaranteed to be different from any other file that existed when .B temp_file was called\&. Raise .B Sys_error if the file could not be created\&. .sp .B "Before3.11.2" no ?temp_dir optional argument .sp .I val open_temp_file : .B ?mode:Pervasives.open_flag list -> .B ?temp_dir:string -> string -> string -> string * Pervasives.out_channel .sp Same as .B Filename\&.temp_file , but returns both the name of a fresh temporary file, and an output channel opened (atomically) on this file\&. This function is more secure than .B temp_file : there is no risk that the temporary file will be modified (e\&.g\&. replaced by a symbolic link) before the program opens it\&. The optional argument .B mode is a list of additional flags to control the opening of the file\&. It can contain one or several of .B Open_append , .B Open_binary , and .B Open_text \&. The default is .B [Open_text] (open in text mode)\&. Raise .B Sys_error if the file could not be opened\&. .sp .B "Before3.11.2" no ?temp_dir optional argument .sp .I val get_temp_dir_name : .B unit -> string .sp The name of the temporary directory: Under Unix, the value of the .B TMPDIR environment variable, or "/tmp" if the variable is not set\&. Under Windows, the value of the .B TEMP environment variable, or "\&." if the variable is not set\&. The temporary directory can be changed with .B Filename\&.set_temp_dir_name \&. .sp .B "Since" 4.00.0 .sp .I val set_temp_dir_name : .B string -> unit .sp Change the temporary directory returned by .B Filename\&.get_temp_dir_name and used by .B Filename\&.temp_file and .B Filename\&.open_temp_file \&. .sp .B "Since" 4.00.0 .sp .I val temp_dir_name : .B string .sp .B "Deprecated." You should use .B Filename\&.get_temp_dir_name instead\&. .sp The name of the initial temporary directory: Under Unix, the value of the .B TMPDIR environment variable, or "/tmp" if the variable is not set\&. Under Windows, the value of the .B TEMP environment variable, or "\&." if the variable is not set\&. .sp .B "Since" 3.09.1 .sp .I val quote : .B string -> string .sp Return a quoted version of a file name, suitable for use as one argument in a command line, escaping all meta\-characters\&. Warning: under Windows, the output is only suitable for use with programs that follow the standard Windows quoting conventions\&. .sp