1Filename(3)                        OCamldoc                        Filename(3)
2
3
4

NAME

6       Filename - Operations on file names.
7

Module

9       Module   Filename
10

Documentation

12       Module Filename
13        : sig end
14
15
16       Operations on file names.
17
18
19
20
21
22
23       val current_dir_name : string
24
25       The conventional name for the current directory (e.g.  .  in Unix).
26
27
28
29       val parent_dir_name : string
30
31       The conventional name for the parent of the current directory (e.g.  ..
32       in Unix).
33
34
35
36       val dir_sep : string
37
38       The directory separator (e.g.  / in Unix).
39
40
41       Since 3.11.2
42
43
44
45       val concat : string -> string -> string
46
47
48       concat dir file returns a file name that designates file file in direc‐
49       tory dir .
50
51
52
53       val is_relative : string -> bool
54
55       Return  true  if  the  file  name is relative to the current directory,
56       false if it is absolute (i.e. in Unix, starts with / ).
57
58
59
60       val is_implicit : string -> bool
61
62       Return true if the file name is relative and does  not  start  with  an
63       explicit reference to the current directory ( ./ or ../ in Unix), false
64       if it starts with an explicit reference to the root  directory  or  the
65       current directory.
66
67
68
69       val check_suffix : string -> string -> bool
70
71
72       check_suffix  name suff returns true if the filename name ends with the
73       suffix suff .
74
75
76
77       val chop_suffix : string -> string -> string
78
79
80       chop_suffix name suff removes the suffix suff from the filename name  .
81       The behavior is undefined if name does not end with the suffix suff .
82
83
84
85       val extension : string -> string
86
87
88       extension name is the shortest suffix ext of name0 where:
89
90
91       - name0 is the longest suffix of name that does not contain a directory
92       separator;
93
94       - ext starts with a period;
95
96       - ext is preceded by at least one non-period character in name0 .
97
98       If such a suffix does not exist, extension name is the empty string.
99
100
101       Since 4.04
102
103
104
105       val remove_extension : string -> string
106
107       Return the given file name without its extension, as defined  in  File‐
108       name.extension  .  If  the extension is empty, the function returns the
109       given file name.
110
111       The following invariant holds for any file name s :
112
113
114       remove_extension s ^ extension s = s
115
116
117
118       Since 4.04
119
120
121
122       val chop_extension : string -> string
123
124       Same as Filename.remove_extension , but raise Invalid_argument  if  the
125       given name has an empty extension.
126
127
128
129       val basename : string -> string
130
131       Split  a  file name into directory name / base file name.  If name is a
132       valid file name, then concat (dirname name) (basename name)  returns  a
133       file  name  which  is  equivalent to name . Moreover, after setting the
134       current directory to dirname name  (with  Sys.chdir  ),  references  to
135       basename  name  (which is a relative file name) designate the same file
136       as name before the call to Sys.chdir .
137
138       This function conforms to the specification  of  POSIX.1-2008  for  the
139       basename utility.
140
141
142
143       val dirname : string -> string
144
145       See Filename.basename .  This function conforms to the specification of
146       POSIX.1-2008 for the dirname utility.
147
148
149
150       val temp_file : ?temp_dir:string -> string -> string -> string
151
152
153       temp_file prefix suffix returns the name of a fresh temporary  file  in
154       the temporary directory.  The base name of the temporary file is formed
155       by concatenating prefix , then a suitably chosen integer  number,  then
156       suffix .  The optional argument temp_dir indicates the temporary direc‐
157       tory  to   use,   defaulting   to   the   current   result   of   File‐
158       name.get_temp_dir_name  .   The  temporary  file is created empty, with
159       permissions 0o600 (readable and writable only by the file owner).   The
160       file  is  guaranteed  to  be different from any other file that existed
161       when temp_file was called.  Raise Sys_error if the file  could  not  be
162       created.
163
164
165       Before3.11.2 no ?temp_dir optional argument
166
167
168
169
170       val  open_temp_file  : ?mode:Pervasives.open_flag list -> ?perms:int ->
171       ?temp_dir:string -> string -> string -> string * Pervasives.out_channel
172
173       Same as Filename.temp_file , but returns both the name of a fresh  tem‐
174       porary  file,  and  an output channel opened (atomically) on this file.
175       This function is more secure than temp_file : there is no risk that the
176       temporary  file  will  be  modified  (e.g. replaced by a symbolic link)
177       before the program opens it.  The optional argument mode is a  list  of
178       additional  flags  to  control the opening of the file.  It can contain
179       one or several of Open_append , Open_binary  ,  and  Open_text  .   The
180       default  is  [Open_text]  (open in text mode). The file is created with
181       permissions perms (defaults to readable and writable only by  the  file
182       owner, 0o600 ).
183
184
185       Before4.03.0 no ?perms optional argument
186
187
188
189       Before3.11.2 no ?temp_dir optional argument
190
191
192
193       Raises Sys_error if the file could not be opened.
194
195
196
197       val get_temp_dir_name : unit -> string
198
199       The  name  of  the  temporary  directory:  Under Unix, the value of the
200       TMPDIR environment variable, or "/tmp" if  the  variable  is  not  set.
201       Under  Windows,  the value of the TEMP environment variable, or "."  if
202       the variable is not set.  The temporary directory can be  changed  with
203       Filename.set_temp_dir_name .
204
205
206       Since 4.00.0
207
208
209
210       val set_temp_dir_name : string -> unit
211
212       Change  the  temporary directory returned by Filename.get_temp_dir_name
213       and used by Filename.temp_file and Filename.open_temp_file .
214
215
216       Since 4.00.0
217
218
219
220       val temp_dir_name : string
221
222       Deprecated.  You should use Filename.get_temp_dir_name instead.
223
224
225       The name of the initial temporary directory: Under Unix, the  value  of
226       the  TMPDIR environment variable, or "/tmp" if the variable is not set.
227       Under Windows, the value of the TEMP environment variable, or  "."   if
228       the variable is not set.
229
230
231       Since 3.09.1
232
233
234
235       val quote : string -> string
236
237       Return  a  quoted version of a file name, suitable for use as one argu‐
238       ment in a command line, escaping all meta-characters.   Warning:  under
239       Windows,  the output is only suitable for use with programs that follow
240       the standard Windows quoting conventions.
241
242
243
244
245
2462018-04-14                          source:                        Filename(3)
Impressum