1Filename(3)                      OCaml library                     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
24       val current_dir_name : string
25
26       The conventional name for the current directory (e.g.  .  in Unix).
27
28
29
30
31       val parent_dir_name : string
32
33       The conventional name for the parent of the current directory (e.g.  ..
34       in Unix).
35
36
37
38
39       val dir_sep : string
40
41       The directory separator (e.g.  / in Unix).
42
43
44
45
46       val concat : string -> string -> string
47
48
49       concat dir file returns a file name that designates file file in direc‐
50       tory dir .
51
52
53
54
55       val is_relative : string -> bool
56
57       Return  true  if  the  file  name is relative to the current directory,
58       false if it is absolute (i.e. in Unix, starts with / ).
59
60
61
62
63       val is_implicit : string -> bool
64
65       Return true if the file name is relative and does  not  start  with  an
66       explicit reference to the current directory ( ./ or ../ in Unix), false
67       if it starts with an explicit reference to the root  directory  or  the
68       current directory.
69
70
71
72
73       val check_suffix : string -> string -> bool
74
75
76       check_suffix  name suff returns true if the filename name ends with the
77       suffix suff .
78
79
80
81
82       val chop_suffix : string -> string -> string
83
84
85       chop_suffix name suff removes the suffix suff from the filename name  .
86       The behavior is undefined if name does not end with the suffix suff .
87
88
89
90
91       val chop_extension : string -> string
92
93       Return  the given file name without its extension. The extension is the
94       shortest suffix starting with a period and not  including  a  directory
95       separator, .xyz for instance.
96
97       Raise Invalid_argument if the given name does not contain an extension.
98
99
100
101
102       val basename : string -> string
103
104       Split  a  file  name  into  directory  name  /  base file name.  concat
105       (dirname name) (basename name) returns a file name which is  equivalent
106       to name . Moreover, after setting the current directory to dirname name
107       (with Sys.chdir ), references to basename name  (which  is  a  relative
108       file name) designate the same file as name before the call to Sys.chdir
109       .
110
111       The result is not specified if the argument is not a  valid  file  name
112       (for example, under Unix if there is a NUL character in the string).
113
114
115
116
117       val dirname : string -> string
118
119       See Filename.basename .
120
121
122
123
124       val temp_file : ?temp_dir:string -> string -> string -> string
125
126
127       temp_file  prefix  suffix returns the name of a fresh temporary file in
128       the temporary directory.  The base name of the temporary file is formed
129       by  concatenating  prefix , then a suitably chosen integer number, then
130       suffix .  The optional argument temp_dir indicates the temporary direc‐
131       tory to use, defaulting to Filename.temp_dir_name .  The temporary file
132       is created empty, with permissions 0o600 (readable and writable only by
133       the file owner).  The file is guaranteed to be different from any other
134       file that existed when temp_file was called.
135
136
137
138
139       val    open_temp_file    :    ?mode:Pervasives.open_flag    list     ->
140       ?temp_dir:string -> string -> string -> string * Pervasives.out_channel
141
142       Same  as Filename.temp_file , but returns both the name of a fresh tem‐
143       porary file, and an output channel opened (atomically)  on  this  file.
144       This function is more secure than temp_file : there is no risk that the
145       temporary file will be modified (e.g.  replaced  by  a  symbolic  link)
146       before  the  program opens it.  The optional argument mode is a list of
147       additional flags to control the opening of the file.   It  can  contain
148       one  or  several  of  Open_append  , Open_binary , and Open_text .  The
149       default is [Open_text] (open in text mode).
150
151
152
153
154       val temp_dir_name : string
155
156       The name of the temporary directory:  Under  Unix,  the  value  of  the
157       TMPDIR  environment  variable,  or  "/tmp"  if the variable is not set.
158       Under Windows, the value of the TEMP environment variable, or  "."   if
159       the variable is not set.
160
161
162
163
164       val quote : string -> string
165
166       Return  a  quoted version of a file name, suitable for use as one argu‐
167       ment in a command line, escaping all meta-characters.   Warning:  under
168       Windows,  the output is only suitable for use with programs that follow
169       the standard Windows quoting conventions.
170
171
172
173
174
175
176OCamldoc                          2017-03-22                       Filename(3)
Impressum