]>
Commit | Line | Data |
---|---|---|
2569938d VZ |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: filename.tex | |
3 | %% Purpose: wxFileName documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: 30.11.01 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) 2001 Vadim Zeitlin | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
12 | \section{\class{wxFileName}}\label{wxfilename} | |
13 | ||
14 | wxFileName encapsulates a file name. This class serves two purposes: first, it | |
15 | provides the functions to split the file names into components and to recombine | |
16 | these components in the full file name which can then be passed to the OS file | |
17 | functions (and \helpref{wxWindows functions}{filefunctions} wrapping them). | |
18 | Second, it includes the functions for working with the files itself. Note that | |
95c00185 | 19 | to change the file data you should use \helpref{wxFile}{wxfile} class instead. |
2569938d VZ |
20 | wxFileName provides functions for working with the file attributes. |
21 | ||
22 | \wxheading{Derived from} | |
23 | ||
24 | No base class | |
25 | ||
26 | \wxheading{Data structures} | |
27 | ||
28 | Many wxFileName methods accept the path format argument which is by\rtfsp | |
29 | {\tt wxPATH\_NATIVE} by default meaning to use the path format native for the | |
30 | current platform. | |
31 | ||
32 | The path format affects the operation of wxFileName functions in several ways: | |
33 | first and foremost, it defines the path separator character to use, but it also | |
34 | affects other things such as whether the path has the drive part or not. | |
35 | ||
36 | \begin{verbatim} | |
37 | enum wxPathFormat | |
38 | { | |
39 | wxPATH_NATIVE = 0, // the path format for the current platform | |
40 | wxPATH_UNIX, | |
41 | wxPATH_MAC, | |
42 | wxPATH_DOS, | |
43 | wxPATH_VMS, | |
44 | ||
45 | wxPATH_BEOS = wxPATH_UNIX, | |
46 | wxPATH_WIN = wxPATH_DOS, | |
47 | wxPATH_OS2 = wxPATH_DOS | |
48 | } | |
49 | \end{verbatim} | |
50 | ||
51 | The kind of normalization to do with the file name: these values can be | |
52 | or'd together to perform several operations at once in\rtfsp | |
53 | \helpref{Normalize}{wxfilenamenormalize}. | |
54 | ||
55 | \begin{verbatim} | |
56 | enum wxPathNormalize | |
57 | { | |
58 | wxPATH_NORM_ENV_VARS = 0x0001, // replace env vars with their values | |
59 | wxPATH_NORM_DOTS = 0x0002, // squeeze all .. and . and prepend cwd | |
60 | wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user | |
61 | wxPATH_NORM_CASE = 0x0008, // if case insensitive => tolower | |
62 | wxPATH_NORM_ABSOLUTE = 0x0010, // make the path absolute | |
63 | wxPATH_NORM_LONG = 0x0020, // make the path the long form | |
64 | wxPATH_NORM_ALL = 0x003f | |
65 | } | |
66 | \end{verbatim} | |
67 | ||
6f91bc33 VZ |
68 | \latexignore{\rtfignore{\wxheading{Function groups}}} |
69 | ||
70 | \membersection{File name format} | |
71 | ||
72 | wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS | |
73 | and VMS formats. Although these formats are quite different, wxFileName tries | |
2edb0bde | 74 | to treat them all in the same generic way. It supposes that all file names |
6f91bc33 VZ |
75 | consist of the following parts: the volume (also known as drive under Windows |
76 | or device under VMS), the path which is a sequence of directory names separated | |
77 | by the \helpref{path separators}{wxfilenamegetpathseparators} and the full | |
78 | filename itself which, in turn, is composed from the base file name and the | |
79 | extension. All of the individual components of the file name may be empty and, | |
80 | for example, the volume name is always empty under Unix, but if they are all | |
81 | empty simultaneously, the filename object is considered to be in an invalid | |
82 | state and \helpref{IsOk}{wxfilenameisok} returns {\tt FALSE} for it. | |
83 | ||
84 | File names can be case-sensitive or not, the function\rtfsp | |
85 | \helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this. | |
86 | ||
87 | The rules for determining if the file name is absolute or relative also depends | |
88 | on the file name format and the only portable way to answer to this question is | |
89 | to use \helpref{IsAbsolute}{wxfilenameisabsolute} method. To ensure that the | |
f7d886af VZ |
90 | filename is absolute you may use \helpref{Normalize}{wxfilenamenormalize}. There |
91 | is also an inverse function \helpref{MakeRelativeTo}{wxfilenamemakerelativeto} | |
2b5f62a0 | 92 | which undoes what \helpref{Normalize(wxPATH\_NORM\_DOTS)}{wxfilenamenormalize} |
f7d886af | 93 | does. |
6f91bc33 VZ |
94 | |
95 | Other functions returning information about the file format provided by this | |
96 | class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp | |
2db991f4 | 97 | \helpref{IsPathSeparator}{wxfilenameispathseparator}. |
6f91bc33 VZ |
98 | |
99 | \helpref{IsRelative}{wxfilenameisrelative} | |
100 | ||
101 | \membersection{File name construction} | |
102 | ||
103 | TODO. | |
104 | ||
105 | \membersection{File tests} | |
106 | ||
107 | Before doing the other tests you should use \helpref{IsOk}{wxfilenameisok} to | |
108 | verify that the filename is well defined. If it is, | |
109 | \helpref{FileExists}{wxfilenamefileexists} can be used to test if a file with | |
110 | such name exists and \helpref{DirExists}{wxfilenamedirexists} - if a directory | |
111 | with this name exists. | |
112 | ||
113 | File names should be compared using \helpref{SameAs}{wxfilenamesameas} method | |
114 | or \helpref{$==$}{wxfilenameoperatorequal}. | |
115 | ||
116 | \membersection{File name components} | |
117 | ||
118 | These functions allow to examine and modify the directories of the path: | |
119 | ||
120 | \helpref{AppendDir}{wxfilenameappenddir}\\ | |
121 | \helpref{InsertDir}{wxfilenameinsertdir}\\ | |
122 | \helpref{GetDirCount}{wxfilenamegetdircount} | |
123 | \helpref{PrependDir}{wxfilenameprependdir}\\ | |
124 | \helpref{RemoveDir}{wxfilenameremovedir} | |
125 | ||
126 | To change the components of the file name individually you can use the | |
127 | following functions: | |
128 | ||
129 | \helpref{GetExt}{wxfilenamegetext}\\ | |
130 | \helpref{GetName}{wxfilenamegetname}\\ | |
131 | \helpref{GetVolume}{wxfilenamegetvolume}\\ | |
132 | \helpref{HasExt}{wxfilenamehasext}\\ | |
133 | \helpref{HasName}{wxfilenamehasname}\\ | |
134 | \helpref{HasVolume}{wxfilenamehasvolume}\\ | |
135 | \helpref{SetExt}{wxfilenamesetext}\\ | |
136 | \helpref{SetName}{wxfilenamesetname}\\ | |
137 | \helpref{SetVolume}{wxfilenamesetvolume}\\ | |
138 | ||
139 | \membersection{Operations} | |
140 | ||
141 | These methods allow to work with the file creation, access and modification | |
6dbb903b VZ |
142 | times. Note that not all filesystems under all platforms implement these times |
143 | in the same way. For example, the access time under Windows has a resolution of | |
144 | one day (so it is really the access date and not time). The access time may be | |
145 | updated when the file is executed or not depending on the platform. | |
6f91bc33 VZ |
146 | |
147 | \helpref{GetModificationTime}{wxfilenamegetmodificationtime}\\ | |
148 | \helpref{GetTimes}{wxfilenamegettimes}\\ | |
149 | \helpref{SetTimes}{wxfilenamesettimes}\\ | |
150 | \helpref{Touch}{wxfilenametouch} | |
151 | ||
152 | Other file system operations functions are: | |
153 | ||
154 | \helpref{Mkdir}{wxfilenamemkdir}\\ | |
155 | \helpref{Rmdir}{wxfilenamermdir} | |
156 | ||
2569938d VZ |
157 | \latexignore{\rtfignore{\wxheading{Members}}} |
158 | ||
6f91bc33 | 159 | \membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename} |
2569938d VZ |
160 | |
161 | \func{}{wxFileName}{\void} | |
162 | ||
163 | Default constructor. | |
164 | ||
2569938d VZ |
165 | \func{}{wxFileName}{\param{const wxFileName\& }{filename}} |
166 | ||
167 | Copy constructor. | |
168 | ||
2569938d VZ |
169 | \func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
170 | ||
95c00185 | 171 | Constructor taking a full filename. If it terminates with a '/', a directory path |
2edb0bde | 172 | is constructed (the name will be empty), otherwise a file name and |
95c00185 | 173 | extension are extracted from it. |
2569938d | 174 | |
2569938d VZ |
175 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
176 | ||
6f91bc33 | 177 | Constructor from a directory name and a file name. |
2569938d VZ |
178 | |
179 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
180 | ||
95c00185 | 181 | Constructor from a directory name, base file name and extension. |
81f25632 VZ |
182 | |
183 | \func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
184 | ||
95c00185 | 185 | Constructor from a volume name, a directory name, base file name and extension. |
2569938d VZ |
186 | |
187 | \membersection{wxFileName::AppendDir}\label{wxfilenameappenddir} | |
188 | ||
189 | \func{void}{AppendDir}{\param{const wxString\& }{dir}} | |
190 | ||
95c00185 | 191 | Appends a directory to the path. |
2569938d VZ |
192 | |
193 | \membersection{wxFileName::Assign}\label{wxfilenameassign} | |
194 | ||
195 | \func{void}{Assign}{\param{const wxFileName\& }{filepath}} | |
196 | ||
2569938d VZ |
197 | \func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
198 | ||
2569938d VZ |
199 | \func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
200 | ||
2569938d VZ |
201 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
202 | ||
2569938d VZ |
203 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
204 | ||
95c00185 | 205 | Creates the file name from various combinations of data. |
2569938d VZ |
206 | |
207 | \membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd} | |
208 | ||
6f91bc33 VZ |
209 | \func{void}{AssignCwd}{\param{const wxString\& }{volume = ""}} |
210 | ||
211 | Makes this object refer to the current working directory on the specified | |
212 | volume (or current volume if {\it volume} is empty). | |
2569938d | 213 | |
6f91bc33 | 214 | \wxheading{See also} |
2569938d | 215 | |
6f91bc33 | 216 | \helpref{GetCwd}{wxfilenamegetcwd} |
2569938d VZ |
217 | |
218 | \membersection{wxFileName::AssignDir}\label{wxfilenameassigndir} | |
219 | ||
220 | \func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
221 | ||
95c00185 | 222 | Sets this file name object to the given directory name. The name and extension |
81f25632 | 223 | will be empty. |
2569938d VZ |
224 | |
225 | \membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir} | |
226 | ||
227 | \func{void}{AssignHomeDir}{\void} | |
228 | ||
95c00185 | 229 | Sets this file name object to the home directory. |
2569938d VZ |
230 | |
231 | \membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename} | |
232 | ||
df22f860 | 233 | \func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} |
2569938d | 234 | |
ade35f11 VZ |
235 | The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to |
236 | create a temporary file and sets this object to the name of the file. If a | |
237 | temporary file couldn't be created, the object is put into the\rtfsp | |
238 | \helpref{invalid}{wxfilenameisok} state. | |
2569938d VZ |
239 | |
240 | \membersection{wxFileName::Clear}\label{wxfilenameclear} | |
241 | ||
242 | \func{void}{Clear}{\void} | |
243 | ||
ade35f11 VZ |
244 | Reset all components to default, uninitialized state. |
245 | ||
02a3b391 | 246 | \membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename} |
ade35f11 | 247 | |
df22f860 | 248 | \func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} |
ade35f11 VZ |
249 | |
250 | Returns a temporary file name starting with the given {\it prefix}. If | |
251 | the {\it prefix} is an absolute path, the temporary file is created in this | |
252 | directory, otherwise it is created in the default system directory for the | |
253 | temporary files or in the current directory. | |
2569938d | 254 | |
df22f860 VZ |
255 | If the function succeeds, the temporary file is actually created. If\rtfsp |
256 | {\it fileTemp} is not {\tt NULL}, this file will be opened using the name of | |
257 | the temporary file. When possible, this is done in an atomic way ensuring that | |
258 | no race condition occurs between the temporary file name generation and opening | |
259 | it which could often lead to security compromise on the multiuser systems. | |
260 | If {\it fileTemp} is {\tt NULL}, the file is only created, but not opened. | |
261 | ||
262 | Under Unix, the temporary file will have read and write permissions for the | |
263 | owner only to minimize the security problems. | |
264 | ||
265 | \wxheading{Parameters} | |
266 | ||
267 | \docparam{prefix}{Prefix to use for the temporary file name construction} | |
268 | ||
269 | \docparam{fileTemp}{The file to open or {\tt NULL} to just get the name} | |
ade35f11 VZ |
270 | |
271 | \wxheading{Return value} | |
272 | ||
273 | The full temporary file name or an empty string on error. | |
2569938d VZ |
274 | |
275 | \membersection{wxFileName::DirExists}\label{wxfilenamedirexists} | |
276 | ||
277 | \func{bool}{DirExists}{\void} | |
278 | ||
2569938d VZ |
279 | \func{bool}{DirExists}{\param{const wxString\& }{dir}} |
280 | ||
95c00185 | 281 | Returns TRUE if the directory with this name exists. |
2569938d VZ |
282 | |
283 | \membersection{wxFileName::DirName}\label{wxfilenamedirname} | |
284 | ||
285 | \func{wxFileName}{DirName}{\param{const wxString\& }{dir}} | |
286 | ||
95c00185 JS |
287 | Returns the directory name. |
288 | ||
2569938d VZ |
289 | \membersection{wxFileName::FileExists}\label{wxfilenamefileexists} |
290 | ||
291 | \func{bool}{FileExists}{\void} | |
292 | ||
2569938d VZ |
293 | \func{bool}{FileExists}{\param{const wxString\& }{file}} |
294 | ||
95c00185 | 295 | Returns TRUE if the file with this name exists. |
2569938d VZ |
296 | |
297 | \membersection{wxFileName::FileName}\label{wxfilenamefilename} | |
298 | ||
299 | \func{wxFileName}{FileName}{\param{const wxString\& }{file}} | |
300 | ||
95c00185 | 301 | Static pseudo constructors. |
2569938d | 302 | |
2569938d VZ |
303 | \membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd} |
304 | ||
6f91bc33 VZ |
305 | \func{wxString}{GetCwd}{\param{const wxString\& }{volume = ""}} |
306 | ||
95c00185 | 307 | Retrieves the value of the current working directory on the specified volume. If |
6f91bc33 VZ |
308 | the volume is empty, the programs current working directory is returned for the |
309 | current volume. | |
310 | ||
311 | \wxheading{Return value} | |
312 | ||
313 | The string containing the current working directory or an empty string on | |
314 | error. | |
2569938d | 315 | |
6f91bc33 VZ |
316 | \wxheading{See also} |
317 | ||
318 | \helpref{AssignCwd}{wxfilenameassigncwd} | |
2569938d VZ |
319 | |
320 | \membersection{wxFileName::GetDirCount}\label{wxfilenamegetdircount} | |
321 | ||
322 | \constfunc{size\_t}{GetDirCount}{\void} | |
323 | ||
95c00185 | 324 | Returns the number of directories in the file name. |
2569938d VZ |
325 | |
326 | \membersection{wxFileName::GetDirs}\label{wxfilenamegetdirs} | |
327 | ||
328 | \constfunc{const wxArrayString\&}{GetDirs}{\void} | |
329 | ||
95c00185 | 330 | Returns the directories in string array form. |
2569938d VZ |
331 | |
332 | \membersection{wxFileName::GetExt}\label{wxfilenamegetext} | |
333 | ||
334 | \constfunc{wxString}{GetExt}{\void} | |
335 | ||
95c00185 | 336 | Returns the file name extension. |
2569938d VZ |
337 | |
338 | \membersection{wxFileName::GetFormat}\label{wxfilenamegetformat} | |
339 | ||
340 | \func{wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
341 | ||
95c00185 | 342 | Returns the canonical path format for this platform. |
2569938d VZ |
343 | |
344 | \membersection{wxFileName::GetFullName}\label{wxfilenamegetfullname} | |
345 | ||
346 | \constfunc{wxString}{GetFullName}{\void} | |
347 | ||
95c00185 | 348 | Returns the full name (including extension but excluding directories). |
2569938d VZ |
349 | |
350 | \membersection{wxFileName::GetFullPath}\label{wxfilenamegetfullpath} | |
351 | ||
352 | \constfunc{wxString}{GetFullPath}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
353 | ||
95c00185 | 354 | Returns the full path with name and extension. |
2569938d VZ |
355 | |
356 | \membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir} | |
357 | ||
358 | \func{wxString}{GetHomeDir}{\void} | |
359 | ||
95c00185 | 360 | Returns the home directory. |
2569938d VZ |
361 | |
362 | \membersection{wxFileName::GetLongPath}\label{wxfilenamegetlongpath} | |
363 | ||
364 | \constfunc{wxString}{GetLongPath}{\void} | |
365 | ||
366 | Return the long form of the path (returns identity on non-Windows platforms) | |
367 | ||
2569938d VZ |
368 | \membersection{wxFileName::GetModificationTime}\label{wxfilenamegetmodificationtime} |
369 | ||
370 | \constfunc{wxDateTime}{GetModificationTime}{\void} | |
371 | ||
95c00185 | 372 | Returns the last time the file was last modified. |
2569938d VZ |
373 | |
374 | \membersection{wxFileName::GetName}\label{wxfilenamegetname} | |
375 | ||
376 | \constfunc{wxString}{GetName}{\void} | |
377 | ||
95c00185 | 378 | Returns the name part of the filename. |
2569938d VZ |
379 | |
380 | \membersection{wxFileName::GetPath}\label{wxfilenamegetpath} | |
381 | ||
33b97389 | 382 | \constfunc{wxString}{GetPath}{\param{int }{flags = $0$}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 383 | |
95c00185 | 384 | Returns the path part of the filename (without the name or extension). The |
33b97389 | 385 | possible flags values are: |
2569938d | 386 | |
d1853d47 | 387 | \twocolwidtha{5cm} |
33b97389 | 388 | \begin{twocollist}\itemsep=0pt |
d1853d47 | 389 | \twocolitem{{\bf wxPATH\_GET\_VOLUME}}{Return the path with the volume (does |
33b97389 | 390 | nothing for the filename formats without volumes)} |
d1853d47 | 391 | \twocolitem{{\bf wxPATH\_GET\_SEPARATOR}}{Return the path with the trailing |
33b97389 VZ |
392 | separator, if this flag is not given there will be no separator at the end of |
393 | the path.} | |
394 | \end{twocollist} | |
395 | ||
396 | \membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator} | |
397 | ||
398 | \func{wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
399 | ||
95c00185 | 400 | Returns the usually used path separator for this format. For all formats but |
33b97389 VZ |
401 | {\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there |
402 | are two of them and the native one, i.e. the backslash is returned by this | |
403 | method. | |
404 | ||
405 | \wxheading{See also} | |
406 | ||
407 | \helpref{GetPathSeparators}{wxfilenamegetpathseparators} | |
2569938d VZ |
408 | |
409 | \membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators} | |
410 | ||
411 | \func{wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
412 | ||
95c00185 | 413 | Returns the string containing all the path separators for this format. For all |
33b97389 | 414 | formats but {\tt wxPATH\_DOS} this string contains only one character but for |
7af3ca16 | 415 | DOS and Windows both {\tt '/'} and {\tt '\textbackslash'} may be used as |
33b97389 VZ |
416 | separators. |
417 | ||
418 | \wxheading{See also} | |
2569938d | 419 | |
33b97389 | 420 | \helpref{GetPathSeparator}{wxfilenamegetpathseparator} |
2569938d | 421 | |
2569938d VZ |
422 | \membersection{wxFileName::GetShortPath}\label{wxfilenamegetshortpath} |
423 | ||
424 | \constfunc{wxString}{GetShortPath}{\void} | |
425 | ||
95c00185 | 426 | Return the short form of the path (returns identity on non-Windows platforms). |
2569938d VZ |
427 | |
428 | \membersection{wxFileName::GetTimes}\label{wxfilenamegettimes} | |
429 | ||
6dbb903b | 430 | \constfunc{bool}{GetTimes}{\param{wxDateTime* }{dtAccess}, \param{wxDateTime* }{dtMod}, \param{wxDateTime* }{dtCreate}} |
2569938d | 431 | |
95c00185 | 432 | Returns the last access, last modification and creation times. The last access |
ebb39671 VZ |
433 | time is updated whenever the file is read or written (or executed in the case |
434 | of Windows), last modification time is only changed when the file is written | |
435 | to. Finally, the creation time is indeed the time when the file was created | |
436 | under Windows and the inode change time under Unix (as it is impossible to | |
437 | retrieve the real file creation time there anyhow) which can also be changed | |
438 | by many operations after the file creation. | |
2569938d | 439 | |
95c00185 | 440 | Any of the pointers may be {\tt NULL} if the corresponding time is not |
ebb39671 VZ |
441 | needed. |
442 | ||
443 | \wxheading{Return value} | |
444 | ||
445 | {\tt TRUE} on success, {\tt FALSE} if we failed to retrieve the times. | |
2569938d VZ |
446 | |
447 | \membersection{wxFileName::GetVolume}\label{wxfilenamegetvolume} | |
448 | ||
449 | \constfunc{wxString}{GetVolume}{\void} | |
450 | ||
ebb39671 VZ |
451 | Returns the string containing the volume for this file name, mepty if it |
452 | doesn't have one or if the file system doesn't support volumes at all (for | |
453 | example, Unix). | |
2569938d VZ |
454 | |
455 | \membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator} | |
456 | ||
457 | \func{wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
458 | ||
95c00185 | 459 | Returns the string separating the volume from the path for this format. |
2569938d VZ |
460 | |
461 | \membersection{wxFileName::HasExt}\label{wxfilenamehasext} | |
462 | ||
463 | \constfunc{bool}{HasExt}{\void} | |
464 | ||
95c00185 | 465 | Returns TRUE if an extension is present. |
2569938d VZ |
466 | |
467 | \membersection{wxFileName::HasName}\label{wxfilenamehasname} | |
468 | ||
469 | \constfunc{bool}{HasName}{\void} | |
470 | ||
95c00185 | 471 | Returns TRUE if a name is present. |
2569938d VZ |
472 | |
473 | \membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume} | |
474 | ||
475 | \constfunc{bool}{HasVolume}{\void} | |
476 | ||
95c00185 | 477 | Returns TRUE if a volume specifier is present. |
2569938d VZ |
478 | |
479 | \membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir} | |
480 | ||
481 | \func{void}{InsertDir}{\param{int }{before}, \param{const wxString\& }{dir}} | |
482 | ||
95c00185 | 483 | Inserts a directory before the zero-based position in the directory list. |
2569938d VZ |
484 | |
485 | \membersection{wxFileName::IsAbsolute}\label{wxfilenameisabsolute} | |
486 | ||
487 | \func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
488 | ||
95c00185 | 489 | Returns TRUE if this filename is absolute. |
2569938d VZ |
490 | |
491 | \membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive} | |
492 | ||
493 | \func{bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
494 | ||
95c00185 | 495 | Returns TRUE if the file names of this type are case-sensitive. |
2569938d VZ |
496 | |
497 | \membersection{wxFileName::IsOk}\label{wxfilenameisok} | |
498 | ||
499 | \constfunc{bool}{IsOk}{\void} | |
500 | ||
ade35f11 VZ |
501 | Returns {\tt TRUE} if the filename is valid, {\tt FALSE} if it is not |
502 | initialized yet. The assignment functions and | |
503 | \helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized, | |
504 | invalid state (the former only do it on failure). | |
2569938d VZ |
505 | |
506 | \membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator} | |
507 | ||
508 | \func{bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
509 | ||
f7d886af | 510 | Returns {\tt TRUE} if the char is a path separator for this format. |
2569938d VZ |
511 | |
512 | \membersection{wxFileName::IsRelative}\label{wxfilenameisrelative} | |
513 | ||
514 | \func{bool}{IsRelative}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
515 | ||
f7d886af | 516 | Returns {\tt TRUE} if this filename is not absolute. |
2569938d | 517 | |
2db991f4 | 518 | \membersection{wxFileName::IsDir}\label{wxfilenameisdir} |
2569938d | 519 | |
2db991f4 | 520 | \constfunc{bool}{IsDir}{\void} |
2569938d | 521 | |
2db991f4 VZ |
522 | Returns {\tt TRUE} if this object represents a directory, {\tt FALSE} otherwise |
523 | (i.e. if it is a file). Note that this method doesn't test whether the | |
524 | directory or file really exists, you should use | |
525 | \helpref{DirExists}{wxfilenamedirexists} or | |
526 | \helpref{FileExists}{wxfilenamefileexists} for this. | |
2569938d | 527 | |
f7d886af VZ |
528 | \membersection{wxFileName::MakeRelativeTo}\label{wxfilenamemakerelativeto} |
529 | ||
530 | \func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = ""}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
531 | ||
532 | This function tries to put this file name in a form relative to {\it pathBase}. | |
533 | In other words, it returns the file name which should be used to access this | |
534 | file if the current directory were {\it pathBase}. | |
535 | ||
536 | \docparam{pathBase}{the directory to use as root, current directory is used by | |
537 | default} | |
538 | ||
539 | \docparam{format}{the file name format, native by default} | |
540 | ||
541 | \wxheading{Return value} | |
542 | ||
543 | {\tt TRUE} if the file name has been changed, {\tt FALSE} if we failed to do | |
544 | anything with it (currently this only happens if the file name is on a volume | |
545 | different from the volume specified by {\it pathBase}). | |
546 | ||
547 | \wxheading{See also} | |
548 | ||
549 | \helpref{Normalize}{wxfilenamenormalize} | |
2569938d VZ |
550 | |
551 | \membersection{wxFileName::Mkdir}\label{wxfilenamemkdir} | |
552 | ||
1527281e | 553 | \func{bool}{Mkdir}{\param{int }{perm = 0777}, \param{int }{flags = $0$}} |
2569938d | 554 | |
1527281e | 555 | \func{static bool}{Mkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}, \param{int }{flags = $0$}} |
2569938d | 556 | |
6f91bc33 | 557 | \docparam{dir}{the directory to create} |
2569938d | 558 | |
6f91bc33 VZ |
559 | \docparam{parm}{the permissions for the newly created directory} |
560 | ||
1527281e VZ |
561 | \docparam{flags}{if the flags contain {\tt wxPATH\_MKDIR\_FULL} flag, |
562 | try to create each directory in the path and also don't return an error | |
563 | if the target directory already exists.} | |
2569938d | 564 | |
6f91bc33 | 565 | \wxheading{Return value} |
2569938d | 566 | |
6f91bc33 VZ |
567 | Returns {\tt TRUE} if the directory was successfully created, {\tt FALSE} |
568 | otherwise. | |
2569938d VZ |
569 | |
570 | \membersection{wxFileName::Normalize}\label{wxfilenamenormalize} | |
571 | ||
32a0d013 | 572 | \func{bool}{Normalize}{\param{int }{flags = wxPATH\_NORM\_ALL}, \param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 573 | |
95c00185 | 574 | Normalize the path: with the default flags value, the path will be |
2569938d VZ |
575 | made absolute, without any ".." and "." and all environment |
576 | variables will be expanded in it | |
577 | this may be done using another (than current) value of cwd | |
578 | ||
2569938d VZ |
579 | \membersection{wxFileName::PrependDir}\label{wxfilenameprependdir} |
580 | ||
581 | \func{void}{PrependDir}{\param{const wxString\& }{dir}} | |
582 | ||
95c00185 | 583 | Prepends a directory name. |
2569938d VZ |
584 | |
585 | \membersection{wxFileName::RemoveDir}\label{wxfilenameremovedir} | |
586 | ||
587 | \func{void}{RemoveDir}{\param{int }{pos}} | |
588 | ||
95c00185 | 589 | Removes a directory name. |
2569938d VZ |
590 | |
591 | \membersection{wxFileName::Rmdir}\label{wxfilenamermdir} | |
592 | ||
593 | \func{bool}{Rmdir}{\void} | |
594 | ||
6f91bc33 | 595 | \func{static bool}{Rmdir}{\param{const wxString\& }{dir}} |
2569938d | 596 | |
95c00185 | 597 | Deletes the specified directory from the file system. |
2569938d VZ |
598 | |
599 | \membersection{wxFileName::SameAs}\label{wxfilenamesameas} | |
600 | ||
2b5f62a0 | 601 | \constfunc{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 602 | |
95c00185 | 603 | Compares the filename using the rules of this platform. |
2569938d VZ |
604 | |
605 | \membersection{wxFileName::SetCwd}\label{wxfilenamesetcwd} | |
606 | ||
607 | \func{bool}{SetCwd}{\void} | |
608 | ||
6f91bc33 | 609 | \func{static bool}{SetCwd}{\param{const wxString\& }{cwd}} |
2569938d | 610 | |
95c00185 | 611 | Changes the current working directory. |
2569938d VZ |
612 | |
613 | \membersection{wxFileName::SetExt}\label{wxfilenamesetext} | |
614 | ||
615 | \func{void}{SetExt}{\param{const wxString\& }{ext}} | |
616 | ||
95c00185 | 617 | Sets the extension of this file name. |
2569938d VZ |
618 | |
619 | \membersection{wxFileName::SetFullName}\label{wxfilenamesetfullname} | |
620 | ||
621 | \func{void}{SetFullName}{\param{const wxString\& }{fullname}} | |
622 | ||
95c00185 | 623 | The full name is the file name and extension (but without the path). |
2569938d VZ |
624 | |
625 | \membersection{wxFileName::SetName}\label{wxfilenamesetname} | |
626 | ||
627 | \func{void}{SetName}{\param{const wxString\& }{name}} | |
628 | ||
95c00185 | 629 | Sets the name. |
2569938d VZ |
630 | |
631 | \membersection{wxFileName::SetTimes}\label{wxfilenamesettimes} | |
632 | ||
6dbb903b | 633 | \func{bool}{SetTimes}{\param{const wxDateTime* }{dtAccess}, \param{const wxDateTime* }{dtMod}, \param{const wxDateTime* }{dtCreate}} |
2569938d | 634 | |
95c00185 | 635 | Sets the file creation and last access/modification times (any of the pointers may be NULL). |
2569938d VZ |
636 | |
637 | \membersection{wxFileName::SetVolume}\label{wxfilenamesetvolume} | |
638 | ||
639 | \func{void}{SetVolume}{\param{const wxString\& }{volume}} | |
640 | ||
95c00185 | 641 | Sets the volume specifier. |
2569938d VZ |
642 | |
643 | \membersection{wxFileName::SplitPath}\label{wxfilenamesplitpath} | |
644 | ||
2bd25c5a | 645 | \func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 646 | |
2bd25c5a | 647 | \func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 648 | |
2bd25c5a VZ |
649 | This function splits a full file name into components: the volume (with the |
650 | first version) path (including the volume in the second version), the base name | |
651 | and the extension. Any of the output parameters ({\it volume}, {\it path}, | |
652 | {\it name} or {\it ext}) may be {\tt NULL} if you are not interested in the | |
653 | value of a particular component. Also, {\it fullpath} may be empty on entry. | |
654 | ||
655 | On return, {\it path} contains the file path (without the trailing separator), | |
656 | {\it name} contains the file name and {\it ext} contains the file extension | |
657 | without leading dot. All three of them may be empty if the corresponding | |
658 | component is. The old contents of the strings pointed to by these parameters | |
659 | will be overwritten in any case (if the pointers are not {\tt NULL}). | |
2569938d VZ |
660 | |
661 | \membersection{wxFileName::Touch}\label{wxfilenametouch} | |
662 | ||
663 | \func{bool}{Touch}{\void} | |
664 | ||
95c00185 | 665 | Sets the access and modification times to the current moment. |
2569938d VZ |
666 | |
667 | \membersection{wxFileName::operator=}\label{wxfilenameoperatorassign} | |
668 | ||
669 | \func{wxFileName\& operator}{operator=}{\param{const wxFileName\& }{filename}} | |
670 | ||
2569938d VZ |
671 | \func{wxFileName\& operator}{operator=}{\param{const wxString\& }{filename}} |
672 | ||
6f91bc33 | 673 | Assigns the new value to this filename object. |
2569938d VZ |
674 | |
675 | \membersection{wxFileName::operator==}\label{wxfilenameoperatorequal} | |
676 | ||
2b5f62a0 | 677 | \constfunc{bool operator}{operator==}{\param{const wxFileName\& }{filename}} |
2569938d | 678 | |
2b5f62a0 | 679 | \constfunc{bool operator}{operator==}{\param{const wxString\& }{filename}} |
2569938d | 680 | |
2b5f62a0 VZ |
681 | Returns {\tt TRUE} if the filenames are equal. The string {\it filenames} is |
682 | interpreted as a path in the native filename format. | |
683 | ||
684 | \membersection{wxFileName::operator!=}\label{wxfilenameoperatornotequal} | |
685 | ||
686 | \constfunc{bool operator}{operator!=}{\param{const wxFileName\& }{filename}} | |
687 | ||
688 | \constfunc{bool operator}{operator!=}{\param{const wxString\& }{filename}} | |
689 | ||
690 | Returns {\tt TRUE} if the filenames are different. The string {\it filenames} | |
691 | is interpreted as a path in the native filename format. | |
6f91bc33 | 692 |