]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/filename.tex
fixed LaTeX markup to suit tex2rtf
[wxWidgets.git] / docs / latex / wx / filename.tex
CommitLineData
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
8795498c 9%% License: wxWindows license
2569938d
VZ
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxFileName}}\label{wxfilename}
13
14wxFileName encapsulates a file name. This class serves two purposes: first, it
15provides the functions to split the file names into components and to recombine
16these components in the full file name which can then be passed to the OS file
fc2171bd 17functions (and \helpref{wxWidgets functions}{filefunctions} wrapping them).
2569938d 18Second, it includes the functions for working with the files itself. Note that
95c00185 19to change the file data you should use \helpref{wxFile}{wxfile} class instead.
2569938d
VZ
20wxFileName provides functions for working with the file attributes.
21
22\wxheading{Derived from}
23
24No base class
25
93ab511d
VZ
26\wxheading{Include files}
27
28<wx/filename.h>
29
2569938d
VZ
30\wxheading{Data structures}
31
32Many wxFileName methods accept the path format argument which is by\rtfsp
33{\tt wxPATH\_NATIVE} by default meaning to use the path format native for the
34current platform.
35
36The path format affects the operation of wxFileName functions in several ways:
37first and foremost, it defines the path separator character to use, but it also
38affects other things such as whether the path has the drive part or not.
39
40\begin{verbatim}
41enum wxPathFormat
42{
43 wxPATH_NATIVE = 0, // the path format for the current platform
44 wxPATH_UNIX,
f363e05c 45 wxPATH_BEOS = wxPATH_UNIX,
2569938d
VZ
46 wxPATH_MAC,
47 wxPATH_DOS,
f363e05c
VZ
48 wxPATH_WIN = wxPATH_DOS,
49 wxPATH_OS2 = wxPATH_DOS,
2569938d
VZ
50 wxPATH_VMS,
51
f363e05c 52 wxPATH_MAX // Not a valid value for specifying path format
2569938d
VZ
53}
54\end{verbatim}
55
6f91bc33
VZ
56\latexignore{\rtfignore{\wxheading{Function groups}}}
57
5bb9aeb2 58
f0e8a2d0 59\membersection{File name format}\label{filenameformat}
6f91bc33
VZ
60
61wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS
62and VMS formats. Although these formats are quite different, wxFileName tries
2edb0bde 63to treat them all in the same generic way. It supposes that all file names
6f91bc33
VZ
64consist of the following parts: the volume (also known as drive under Windows
65or device under VMS), the path which is a sequence of directory names separated
66by the \helpref{path separators}{wxfilenamegetpathseparators} and the full
67filename itself which, in turn, is composed from the base file name and the
68extension. All of the individual components of the file name may be empty and,
69for example, the volume name is always empty under Unix, but if they are all
70empty simultaneously, the filename object is considered to be in an invalid
0894707e 71state and \helpref{IsOk}{wxfilenameisok} returns {\tt false} for it.
6f91bc33
VZ
72
73File names can be case-sensitive or not, the function\rtfsp
74\helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this.
75
76The rules for determining if the file name is absolute or relative also depends
77on the file name format and the only portable way to answer to this question is
78to use \helpref{IsAbsolute}{wxfilenameisabsolute} method. To ensure that the
0894707e 79filename is absolute you may use \helpref{MakeAbsolute}{wxfilenamemakeabsolute}.
d2c2afc9 80There is also an inverse function
0894707e
VS
81\helpref{MakeRelativeTo}{wxfilenamemakerelativeto} which undoes what
82\helpref{Normalize(wxPATH\_NORM\_DOTS)}{wxfilenamenormalize} does.
6f91bc33
VZ
83
84Other functions returning information about the file format provided by this
85class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp
2db991f4 86\helpref{IsPathSeparator}{wxfilenameispathseparator}.
6f91bc33
VZ
87
88\helpref{IsRelative}{wxfilenameisrelative}
89
5bb9aeb2 90
f0e8a2d0 91\membersection{File name construction}\label{filenameconstruction}
6f91bc33
VZ
92
93TODO.
94
5bb9aeb2 95
f0e8a2d0 96\membersection{File tests}\label{filetests}
6f91bc33
VZ
97
98Before doing the other tests you should use \helpref{IsOk}{wxfilenameisok} to
99verify that the filename is well defined. If it is,
100\helpref{FileExists}{wxfilenamefileexists} can be used to test if a file with
101such name exists and \helpref{DirExists}{wxfilenamedirexists} - if a directory
102with this name exists.
103
104File names should be compared using \helpref{SameAs}{wxfilenamesameas} method
105or \helpref{$==$}{wxfilenameoperatorequal}.
106
5bb9aeb2 107
f0e8a2d0 108\membersection{File name components}\label{filenamecomponents}
6f91bc33 109
2458d90b
VZ
110These functions allow to examine and modify the individual directories of the
111path:
6f91bc33
VZ
112
113\helpref{AppendDir}{wxfilenameappenddir}\\
114\helpref{InsertDir}{wxfilenameinsertdir}\\
115\helpref{GetDirCount}{wxfilenamegetdircount}
116\helpref{PrependDir}{wxfilenameprependdir}\\
2458d90b
VZ
117\helpref{RemoveDir}{wxfilenameremovedir}\\
118\helpref{RemoveLastDir}{wxfilenameremovelastdir}
6f91bc33
VZ
119
120To change the components of the file name individually you can use the
121following functions:
122
123\helpref{GetExt}{wxfilenamegetext}\\
124\helpref{GetName}{wxfilenamegetname}\\
125\helpref{GetVolume}{wxfilenamegetvolume}\\
126\helpref{HasExt}{wxfilenamehasext}\\
127\helpref{HasName}{wxfilenamehasname}\\
128\helpref{HasVolume}{wxfilenamehasvolume}\\
129\helpref{SetExt}{wxfilenamesetext}\\
0b40f3d8
RR
130\helpref{ClearExt}{wxfilenameclearext}\\
131\helpref{SetEmptyExt}{wxfilenamesetemptyext}\\
6f91bc33
VZ
132\helpref{SetName}{wxfilenamesetname}\\
133\helpref{SetVolume}{wxfilenamesetvolume}\\
134
5bb9aeb2 135
f0e8a2d0 136\membersection{Operations}\label{filenameoperations}
6f91bc33
VZ
137
138These methods allow to work with the file creation, access and modification
6dbb903b
VZ
139times. Note that not all filesystems under all platforms implement these times
140in the same way. For example, the access time under Windows has a resolution of
141one day (so it is really the access date and not time). The access time may be
142updated when the file is executed or not depending on the platform.
6f91bc33
VZ
143
144\helpref{GetModificationTime}{wxfilenamegetmodificationtime}\\
145\helpref{GetTimes}{wxfilenamegettimes}\\
146\helpref{SetTimes}{wxfilenamesettimes}\\
147\helpref{Touch}{wxfilenametouch}
148
149Other file system operations functions are:
150
151\helpref{Mkdir}{wxfilenamemkdir}\\
152\helpref{Rmdir}{wxfilenamermdir}
153
2569938d
VZ
154\latexignore{\rtfignore{\wxheading{Members}}}
155
5bb9aeb2 156
6f91bc33 157\membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename}
2569938d
VZ
158
159\func{}{wxFileName}{\void}
160
161Default constructor.
162
2569938d
VZ
163\func{}{wxFileName}{\param{const wxFileName\& }{filename}}
164
165Copy constructor.
166
2569938d
VZ
167\func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
168
95c00185 169Constructor taking a full filename. If it terminates with a '/', a directory path
2edb0bde 170is constructed (the name will be empty), otherwise a file name and
95c00185 171extension are extracted from it.
2569938d 172
2569938d
VZ
173\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
174
6f91bc33 175Constructor from a directory name and a file name.
2569938d
VZ
176
177\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
178
95c00185 179Constructor from a directory name, base file name and extension.
81f25632
VZ
180
181\func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
182
95c00185 183Constructor from a volume name, a directory name, base file name and extension.
2569938d 184
5bb9aeb2 185
2569938d
VZ
186\membersection{wxFileName::AppendDir}\label{wxfilenameappenddir}
187
188\func{void}{AppendDir}{\param{const wxString\& }{dir}}
189
5bb9aeb2
VZ
190Appends a directory component to the path. This component should contain a
191single directory name level, i.e. not contain any path or volume separators nor
192should it be empty, otherwise the function does nothing (and generates an
193assert failure in debug build).
194
2569938d
VZ
195
196\membersection{wxFileName::Assign}\label{wxfilenameassign}
197
198\func{void}{Assign}{\param{const wxFileName\& }{filepath}}
199
2569938d
VZ
200\func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
201
dfecbee5
VZ
202\func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{bool }{hasExt}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
203
2569938d
VZ
204\func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
205
2569938d
VZ
206\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
207
2569938d
VZ
208\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
209
95c00185 210Creates the file name from various combinations of data.
2569938d 211
5bb9aeb2 212
2569938d
VZ
213\membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd}
214
f363e05c 215\func{static void}{AssignCwd}{\param{const wxString\& }{volume = wxEmptyString}}
6f91bc33
VZ
216
217Makes this object refer to the current working directory on the specified
218volume (or current volume if {\it volume} is empty).
2569938d 219
6f91bc33 220\wxheading{See also}
2569938d 221
6f91bc33 222\helpref{GetCwd}{wxfilenamegetcwd}
2569938d 223
5bb9aeb2 224
2569938d
VZ
225\membersection{wxFileName::AssignDir}\label{wxfilenameassigndir}
226
227\func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
228
95c00185 229Sets this file name object to the given directory name. The name and extension
81f25632 230will be empty.
2569938d 231
5bb9aeb2 232
2569938d
VZ
233\membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir}
234
235\func{void}{AssignHomeDir}{\void}
236
95c00185 237Sets this file name object to the home directory.
2569938d 238
5bb9aeb2 239
2569938d
VZ
240\membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename}
241
df22f860 242\func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}}
2569938d 243
ade35f11
VZ
244The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to
245create a temporary file and sets this object to the name of the file. If a
246temporary file couldn't be created, the object is put into the\rtfsp
247\helpref{invalid}{wxfilenameisok} state.
2569938d 248
5bb9aeb2 249
2569938d
VZ
250\membersection{wxFileName::Clear}\label{wxfilenameclear}
251
252\func{void}{Clear}{\void}
253
ade35f11
VZ
254Reset all components to default, uninitialized state.
255
5bb9aeb2 256
0b40f3d8
RR
257\membersection{wxFileName::ClearExt}\label{wxfilenameclearext}
258
259\func{void}{SetClearExt}{\void}
260
261Removes the extension from the file name resulting in a
262file name with no trailing dot.
263
264\wxheading{See also}
265
266\helpref{SetExt}{wxfilenamesetext}
267\helpref{SetEmptyExt}{wxfilenamesetemptyext}
268
02a3b391 269\membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename}
ade35f11 270
df22f860 271\func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}}
ade35f11
VZ
272
273Returns a temporary file name starting with the given {\it prefix}. If
274the {\it prefix} is an absolute path, the temporary file is created in this
275directory, otherwise it is created in the default system directory for the
276temporary files or in the current directory.
2569938d 277
df22f860
VZ
278If the function succeeds, the temporary file is actually created. If\rtfsp
279{\it fileTemp} is not {\tt NULL}, this file will be opened using the name of
280the temporary file. When possible, this is done in an atomic way ensuring that
281no race condition occurs between the temporary file name generation and opening
282it which could often lead to security compromise on the multiuser systems.
283If {\it fileTemp} is {\tt NULL}, the file is only created, but not opened.
284
285Under Unix, the temporary file will have read and write permissions for the
286owner only to minimize the security problems.
287
288\wxheading{Parameters}
289
290\docparam{prefix}{Prefix to use for the temporary file name construction}
291
292\docparam{fileTemp}{The file to open or {\tt NULL} to just get the name}
ade35f11
VZ
293
294\wxheading{Return value}
295
296The full temporary file name or an empty string on error.
2569938d 297
5bb9aeb2 298
2569938d
VZ
299\membersection{wxFileName::DirExists}\label{wxfilenamedirexists}
300
8e41796c 301\constfunc{bool}{DirExists}{\void}
2569938d 302
8e41796c 303\func{static bool}{DirExists}{\param{const wxString\& }{dir}}
2569938d 304
f363e05c 305Returns {\tt true} if the directory with this name exists.
2569938d 306
5bb9aeb2 307
2569938d
VZ
308\membersection{wxFileName::DirName}\label{wxfilenamedirname}
309
520200fd
VZ
310\func{static wxFileName}{DirName}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
311
312Returns the object corresponding to the directory with the given name.
313The {\it dir} parameter may have trailing path separator or not.
2569938d 314
95c00185 315
5bb9aeb2 316
2569938d
VZ
317\membersection{wxFileName::FileExists}\label{wxfilenamefileexists}
318
8e41796c 319\constfunc{bool}{FileExists}{\void}
2569938d 320
8e41796c 321\func{static bool}{FileExists}{\param{const wxString\& }{file}}
2569938d 322
f363e05c 323Returns {\tt true} if the file with this name exists.
2569938d 324
8e41796c
VZ
325\wxheading{See also}
326
327\helpref{DirExists}{wxfilenamedirexists}
328
520200fd 329
5bb9aeb2 330
2569938d
VZ
331\membersection{wxFileName::FileName}\label{wxfilenamefilename}
332
520200fd
VZ
333\func{static wxFileName}{FileName}{\param{const wxString\& }{file}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
334
335Returns the file name object corresponding to the given {\it file}. This
336function exists mainly for symmetry with \helpref{DirName}{wxfilenamedirname}.
2569938d 337
2569938d 338
5bb9aeb2 339
2569938d
VZ
340\membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd}
341
f363e05c 342\func{static wxString}{GetCwd}{\param{const wxString\& }{volume = ""}}
6f91bc33 343
95c00185 344Retrieves the value of the current working directory on the specified volume. If
43e8916f 345the volume is empty, the program's current working directory is returned for the
6f91bc33
VZ
346current volume.
347
348\wxheading{Return value}
349
350The string containing the current working directory or an empty string on
351error.
2569938d 352
6f91bc33
VZ
353\wxheading{See also}
354
355\helpref{AssignCwd}{wxfilenameassigncwd}
2569938d 356
5bb9aeb2 357
2569938d
VZ
358\membersection{wxFileName::GetDirCount}\label{wxfilenamegetdircount}
359
360\constfunc{size\_t}{GetDirCount}{\void}
361
95c00185 362Returns the number of directories in the file name.
2569938d 363
5bb9aeb2 364
2569938d
VZ
365\membersection{wxFileName::GetDirs}\label{wxfilenamegetdirs}
366
367\constfunc{const wxArrayString\&}{GetDirs}{\void}
368
95c00185 369Returns the directories in string array form.
2569938d 370
5bb9aeb2 371
2569938d
VZ
372\membersection{wxFileName::GetExt}\label{wxfilenamegetext}
373
374\constfunc{wxString}{GetExt}{\void}
375
95c00185 376Returns the file name extension.
2569938d 377
5bb9aeb2 378
f363e05c
VZ
379\membersection{wxFileName::GetForbiddenChars}\label{wxfilenamegetforbiddenchars}
380
381\func{static wxString}{GetForbiddenChars}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
382
383Returns the characters that can't be used in filenames and directory names for the specified format.
384
5bb9aeb2 385
2569938d
VZ
386\membersection{wxFileName::GetFormat}\label{wxfilenamegetformat}
387
f363e05c 388\func{static wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 389
95c00185 390Returns the canonical path format for this platform.
2569938d 391
5bb9aeb2 392
2569938d
VZ
393\membersection{wxFileName::GetFullName}\label{wxfilenamegetfullname}
394
395\constfunc{wxString}{GetFullName}{\void}
396
95c00185 397Returns the full name (including extension but excluding directories).
2569938d 398
5bb9aeb2 399
2569938d
VZ
400\membersection{wxFileName::GetFullPath}\label{wxfilenamegetfullpath}
401
402\constfunc{wxString}{GetFullPath}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
403
95c00185 404Returns the full path with name and extension.
2569938d 405
5bb9aeb2 406
2569938d
VZ
407\membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir}
408
f363e05c 409\func{static wxString}{GetHomeDir}{\void}
2569938d 410
95c00185 411Returns the home directory.
2569938d 412
5bb9aeb2 413
2569938d
VZ
414\membersection{wxFileName::GetLongPath}\label{wxfilenamegetlongpath}
415
416\constfunc{wxString}{GetLongPath}{\void}
417
418Return the long form of the path (returns identity on non-Windows platforms)
419
5bb9aeb2 420
2569938d
VZ
421\membersection{wxFileName::GetModificationTime}\label{wxfilenamegetmodificationtime}
422
423\constfunc{wxDateTime}{GetModificationTime}{\void}
424
95c00185 425Returns the last time the file was last modified.
2569938d 426
5bb9aeb2 427
2569938d
VZ
428\membersection{wxFileName::GetName}\label{wxfilenamegetname}
429
430\constfunc{wxString}{GetName}{\void}
431
4e43c815
VZ
432Returns the name part of the filename (without extension).
433
434\wxheading{See also}
435
436\helpref{GetFullName}{wxfilenamegetfullname}
437
2569938d 438
5bb9aeb2 439
2569938d
VZ
440\membersection{wxFileName::GetPath}\label{wxfilenamegetpath}
441
93fa67c0 442\constfunc{wxString}{GetPath}{\param{int }{flags = {\tt wxPATH\_GET\_VOLUME}}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 443
95c00185 444Returns the path part of the filename (without the name or extension). The
33b97389 445possible flags values are:
2569938d 446
d1853d47 447\twocolwidtha{5cm}
33b97389 448\begin{twocollist}\itemsep=0pt
d1853d47 449\twocolitem{{\bf wxPATH\_GET\_VOLUME}}{Return the path with the volume (does
93fa67c0
VZ
450nothing for the filename formats without volumes), otherwise the path without
451volume part is returned.}
d1853d47 452\twocolitem{{\bf wxPATH\_GET\_SEPARATOR}}{Return the path with the trailing
33b97389
VZ
453separator, if this flag is not given there will be no separator at the end of
454the path.}
455\end{twocollist}
456
5bb9aeb2 457
33b97389
VZ
458\membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator}
459
f363e05c 460\func{static wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
33b97389 461
95c00185 462Returns the usually used path separator for this format. For all formats but
33b97389
VZ
463{\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there
464are two of them and the native one, i.e. the backslash is returned by this
465method.
466
467\wxheading{See also}
468
469\helpref{GetPathSeparators}{wxfilenamegetpathseparators}
2569938d 470
5bb9aeb2 471
2569938d
VZ
472\membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators}
473
f363e05c 474\func{static wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 475
95c00185 476Returns the string containing all the path separators for this format. For all
33b97389 477formats but {\tt wxPATH\_DOS} this string contains only one character but for
7af3ca16 478DOS and Windows both {\tt '/'} and {\tt '\textbackslash'} may be used as
33b97389
VZ
479separators.
480
481\wxheading{See also}
2569938d 482
33b97389 483\helpref{GetPathSeparator}{wxfilenamegetpathseparator}
2569938d 484
5bb9aeb2 485
f1e77933
VZ
486\membersection{wxFileName::GetPathTerminators}\label{wxfilenamegetpathterminators}
487
488\func{static wxString}{GetPathTerminators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
489
490Returns the string of characters which may terminate the path part. This is the
491same as \helpref{GetPathSeparators}{wxfilenamegetpathseparators} except for VMS
492path format where $]$ is used at the end of the path part.
493
494
2569938d
VZ
495\membersection{wxFileName::GetShortPath}\label{wxfilenamegetshortpath}
496
497\constfunc{wxString}{GetShortPath}{\void}
498
95c00185 499Return the short form of the path (returns identity on non-Windows platforms).
2569938d 500
5bb9aeb2 501
2569938d
VZ
502\membersection{wxFileName::GetTimes}\label{wxfilenamegettimes}
503
6dbb903b 504\constfunc{bool}{GetTimes}{\param{wxDateTime* }{dtAccess}, \param{wxDateTime* }{dtMod}, \param{wxDateTime* }{dtCreate}}
2569938d 505
95c00185 506Returns the last access, last modification and creation times. The last access
ebb39671
VZ
507time is updated whenever the file is read or written (or executed in the case
508of Windows), last modification time is only changed when the file is written
509to. Finally, the creation time is indeed the time when the file was created
510under Windows and the inode change time under Unix (as it is impossible to
511retrieve the real file creation time there anyhow) which can also be changed
512by many operations after the file creation.
2569938d 513
95c00185 514Any of the pointers may be {\tt NULL} if the corresponding time is not
ebb39671
VZ
515needed.
516
517\wxheading{Return value}
518
0894707e 519{\tt true} on success, {\tt false} if we failed to retrieve the times.
2569938d 520
5bb9aeb2 521
2569938d
VZ
522\membersection{wxFileName::GetVolume}\label{wxfilenamegetvolume}
523
524\constfunc{wxString}{GetVolume}{\void}
525
f70c0443 526Returns the string containing the volume for this file name, empty if it
ebb39671
VZ
527doesn't have one or if the file system doesn't support volumes at all (for
528example, Unix).
2569938d 529
5bb9aeb2 530
2569938d
VZ
531\membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator}
532
f363e05c 533\func{static wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 534
95c00185 535Returns the string separating the volume from the path for this format.
2569938d 536
5bb9aeb2 537
2569938d
VZ
538\membersection{wxFileName::HasExt}\label{wxfilenamehasext}
539
540\constfunc{bool}{HasExt}{\void}
541
f363e05c 542Returns {\tt true} if an extension is present.
2569938d 543
5bb9aeb2 544
2569938d
VZ
545\membersection{wxFileName::HasName}\label{wxfilenamehasname}
546
547\constfunc{bool}{HasName}{\void}
548
f363e05c 549Returns {\tt true} if a name is present.
2569938d 550
5bb9aeb2 551
2569938d
VZ
552\membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume}
553
554\constfunc{bool}{HasVolume}{\void}
555
f363e05c 556Returns {\tt true} if a volume specifier is present.
2569938d 557
5bb9aeb2 558
2569938d
VZ
559\membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir}
560
2458d90b 561\func{void}{InsertDir}{\param{size\_t }{before}, \param{const wxString\& }{dir}}
2569938d 562
5bb9aeb2
VZ
563Inserts a directory component before the zero-based position in the directory
564list. Please see \helpref{AppendDir}{wxfilenameappenddir} for important notes.
565
2569938d
VZ
566
567\membersection{wxFileName::IsAbsolute}\label{wxfilenameisabsolute}
568
569\func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
570
f363e05c 571Returns {\tt true} if this filename is absolute.
2569938d 572
5bb9aeb2 573
2569938d
VZ
574\membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive}
575
f363e05c 576\func{static bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 577
f363e05c 578Returns {\tt true} if the file names of this type are case-sensitive.
2569938d 579
5bb9aeb2 580
2569938d
VZ
581\membersection{wxFileName::IsOk}\label{wxfilenameisok}
582
583\constfunc{bool}{IsOk}{\void}
584
0894707e 585Returns {\tt true} if the filename is valid, {\tt false} if it is not
ade35f11
VZ
586initialized yet. The assignment functions and
587\helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized,
588invalid state (the former only do it on failure).
2569938d 589
5bb9aeb2 590
2569938d
VZ
591\membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator}
592
f363e05c 593\func{static bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 594
0894707e 595Returns {\tt true} if the char is a path separator for this format.
2569938d 596
5bb9aeb2 597
2569938d
VZ
598\membersection{wxFileName::IsRelative}\label{wxfilenameisrelative}
599
600\func{bool}{IsRelative}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
601
0894707e 602Returns {\tt true} if this filename is not absolute.
2569938d 603
5bb9aeb2 604
2db991f4 605\membersection{wxFileName::IsDir}\label{wxfilenameisdir}
2569938d 606
2db991f4 607\constfunc{bool}{IsDir}{\void}
2569938d 608
0894707e 609Returns {\tt true} if this object represents a directory, {\tt false} otherwise
2db991f4
VZ
610(i.e. if it is a file). Note that this method doesn't test whether the
611directory or file really exists, you should use
612\helpref{DirExists}{wxfilenamedirexists} or
613\helpref{FileExists}{wxfilenamefileexists} for this.
2569938d 614
5ab2950d
JS
615\membersection{wxFileName::MacFindDefaultTypeAndCreator}\label{wxfilenamemacfinddefaulttypeandcreator}
616
617\func{static bool}{MacFindDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32* }{type}, \param{wxUint32* }{creator}}
618
619On Mac OS, gets the common type and creator for the given extension.
620
621\membersection{wxFileName::MacRegisterDefaultTypeAndCreator}\label{wxfilenamemacregisterdefaulttypeandcreator}
622
623\func{static void}{MacRegisterDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32 }{type}, \param{wxUint32 }{creator}}
624
625On Mac OS, registers application defined extensions and their default type and creator.
626
627\membersection{wxFileName::MacSetDefaultTypeAndCreator}\label{wxfilenamemacsetdefaulttypeandcreator}
628
629\func{bool}{MacSetDefaultTypeAndCreator}{\void}
630
631On Mac OS, looks up the appropriate type and creator from the registration and then sets it.
5bb9aeb2 632
0894707e
VS
633\membersection{wxFileName::MakeAbsolute}\label{wxfilenamemakeabsolute}
634
635\func{bool}{MakeAbsolute}{\param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
636
637Make the file name absolute. This is a shortcut for
638{\tt \helpref{Normalize}{wxfilenamenormalize}(wxPATH\_NORM\_DOTS | wxPATH\_NORM\_ABSOLUTE | wxPATH\_NORM\_TILDE, cwd, format)}.
639
640\wxheading{See also}
641
642\helpref{MakeRelativeTo}{wxfilenamemakerelativeto},
643\helpref{Normalize}{wxfilenamenormalize},
644\helpref{IsAbsolute}{wxfilenameisabsolute}
645
5bb9aeb2 646
f7d886af
VZ
647\membersection{wxFileName::MakeRelativeTo}\label{wxfilenamemakerelativeto}
648
f363e05c 649\func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
f7d886af
VZ
650
651This function tries to put this file name in a form relative to {\it pathBase}.
652In other words, it returns the file name which should be used to access this
653file if the current directory were {\it pathBase}.
654
655\docparam{pathBase}{the directory to use as root, current directory is used by
656default}
657
658\docparam{format}{the file name format, native by default}
659
660\wxheading{Return value}
661
0894707e 662{\tt true} if the file name has been changed, {\tt false} if we failed to do
f7d886af
VZ
663anything with it (currently this only happens if the file name is on a volume
664different from the volume specified by {\it pathBase}).
665
666\wxheading{See also}
667
668\helpref{Normalize}{wxfilenamenormalize}
2569938d 669
5bb9aeb2 670
2569938d
VZ
671\membersection{wxFileName::Mkdir}\label{wxfilenamemkdir}
672
1527281e 673\func{bool}{Mkdir}{\param{int }{perm = 0777}, \param{int }{flags = $0$}}
2569938d 674
1527281e 675\func{static bool}{Mkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}, \param{int }{flags = $0$}}
2569938d 676
6f91bc33 677\docparam{dir}{the directory to create}
2569938d 678
6f91bc33
VZ
679\docparam{parm}{the permissions for the newly created directory}
680
1527281e
VZ
681\docparam{flags}{if the flags contain {\tt wxPATH\_MKDIR\_FULL} flag,
682try to create each directory in the path and also don't return an error
683if the target directory already exists.}
2569938d 684
6f91bc33 685\wxheading{Return value}
2569938d 686
0894707e 687Returns {\tt true} if the directory was successfully created, {\tt false}
6f91bc33 688otherwise.
2569938d 689
5bb9aeb2 690
2569938d
VZ
691\membersection{wxFileName::Normalize}\label{wxfilenamenormalize}
692
32a0d013 693\func{bool}{Normalize}{\param{int }{flags = wxPATH\_NORM\_ALL}, \param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 694
0894707e 695Normalize the path. With the default flags value, the path will be
2569938d 696made absolute, without any ".." and "." and all environment
0894707e
VS
697variables will be expanded in it.
698
699\docparam{flags}{The kind of normalization to do with the file name. It can be
700any or-combination of the following constants:
d2c2afc9 701
0894707e
VS
702\begin{twocollist}
703\twocolitem{{\bf wxPATH\_NORM\_ENV\_VARS}}{replace env vars with their values}
704\twocolitem{{\bf wxPATH\_NORM\_DOTS}}{squeeze all .. and . and prepend cwd}
705\twocolitem{{\bf wxPATH\_NORM\_TILDE}}{Unix only: replace ~ and ~user}
08890e27 706\twocolitem{{\bf wxPATH\_NORM\_CASE}}{if filesystem is case insensitive, transform to lower case}
0894707e
VS
707\twocolitem{{\bf wxPATH\_NORM\_ABSOLUTE}}{make the path absolute}
708\twocolitem{{\bf wxPATH\_NORM\_LONG}}{make the path the long form}
21f60945 709\twocolitem{{\bf wxPATH\_NORM\_SHORTCUT}}{resolve if it is a shortcut (Windows only)}
ef92f440 710\twocolitem{{\bf wxPATH\_NORM\_ALL}}{all of previous flags except \texttt{wxPATH\_NORM\_CASE}}
0894707e 711\end{twocollist}
d2c2afc9 712}%
0894707e
VS
713
714\docparam{cwd}{If not empty, this directory will be used instead of current
715working directory in normalization.}
716
717\docparam{format}{The file name format, native by default.}
2569938d 718
5bb9aeb2 719
2569938d
VZ
720\membersection{wxFileName::PrependDir}\label{wxfilenameprependdir}
721
722\func{void}{PrependDir}{\param{const wxString\& }{dir}}
723
5bb9aeb2
VZ
724Prepends a directory to the file path. Please see
725\helpref{AppendDir}{wxfilenameappenddir} for important notes.
726
727
2569938d
VZ
728
729\membersection{wxFileName::RemoveDir}\label{wxfilenameremovedir}
730
2458d90b 731\func{void}{RemoveDir}{\param{size\_t }{pos}}
2569938d 732
2458d90b
VZ
733Removes the specified directory component from the path.
734
735\wxheading{See also}
736
737\helpref{GetDirCount}{wxfilenamegetdircount}
738
739
740\membersection{wxFileName::RemoveLastDir}\label{wxfilenameremovelastdir}
741
742\func{void}{RemoveLastDir}{\void}
743
744Removes last directory component from the path.
2569938d 745
5bb9aeb2 746
2569938d
VZ
747\membersection{wxFileName::Rmdir}\label{wxfilenamermdir}
748
749\func{bool}{Rmdir}{\void}
750
6f91bc33 751\func{static bool}{Rmdir}{\param{const wxString\& }{dir}}
2569938d 752
95c00185 753Deletes the specified directory from the file system.
2569938d 754
5bb9aeb2 755
2569938d
VZ
756\membersection{wxFileName::SameAs}\label{wxfilenamesameas}
757
2b5f62a0 758\constfunc{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 759
95c00185 760Compares the filename using the rules of this platform.
2569938d 761
5bb9aeb2 762
2569938d
VZ
763\membersection{wxFileName::SetCwd}\label{wxfilenamesetcwd}
764
765\func{bool}{SetCwd}{\void}
766
6f91bc33 767\func{static bool}{SetCwd}{\param{const wxString\& }{cwd}}
2569938d 768
95c00185 769Changes the current working directory.
2569938d 770
5bb9aeb2 771
2569938d
VZ
772\membersection{wxFileName::SetExt}\label{wxfilenamesetext}
773
774\func{void}{SetExt}{\param{const wxString\& }{ext}}
775
0b40f3d8
RR
776Sets the extension of the file name. Setting an empty string
777as the extension will remove the extension resulting in a file
778name without a trailing dot, unlike a call to
779\helpref{SetEmptyExt}{wxfilenamesetemptyext}.
780
781\wxheading{See also}
782
783\helpref{SetEmptyExt}{wxfilenamesetemptyext}
784\helpref{ClearExt}{wxfilenameclearext}
785
786\membersection{wxFileName::SetEmptyExt}\label{wxfilenamesetemptyext}
787
788\func{void}{SetEmptyExt}{\void}
789
790Sets the extension of the file name to be an empty extension.
791This is different from having no extension at all as the file
792name will have a trailing dot after a call to this method.
793
794\wxheading{See also}
2569938d 795
0b40f3d8
RR
796\helpref{SetExt}{wxfilenamesetext}
797\helpref{ClearExt}{wxfilenameclearext}
5bb9aeb2 798
2569938d
VZ
799\membersection{wxFileName::SetFullName}\label{wxfilenamesetfullname}
800
801\func{void}{SetFullName}{\param{const wxString\& }{fullname}}
802
95c00185 803The full name is the file name and extension (but without the path).
2569938d 804
5bb9aeb2 805
2569938d
VZ
806\membersection{wxFileName::SetName}\label{wxfilenamesetname}
807
808\func{void}{SetName}{\param{const wxString\& }{name}}
809
4e43c815
VZ
810Sets the name part (without extension).
811
812\wxheading{See also}
813
814\helpref{SetFullName}{wxfilenamesetfullname}
2569938d 815
5bb9aeb2 816
2569938d
VZ
817\membersection{wxFileName::SetTimes}\label{wxfilenamesettimes}
818
6dbb903b 819\func{bool}{SetTimes}{\param{const wxDateTime* }{dtAccess}, \param{const wxDateTime* }{dtMod}, \param{const wxDateTime* }{dtCreate}}
2569938d 820
95c00185 821Sets the file creation and last access/modification times (any of the pointers may be NULL).
2569938d 822
5bb9aeb2 823
2569938d
VZ
824\membersection{wxFileName::SetVolume}\label{wxfilenamesetvolume}
825
826\func{void}{SetVolume}{\param{const wxString\& }{volume}}
827
95c00185 828Sets the volume specifier.
2569938d 829
5bb9aeb2 830
2569938d
VZ
831\membersection{wxFileName::SplitPath}\label{wxfilenamesplitpath}
832
dfecbee5
VZ
833\func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{bool }{*hasExt = \texttt{NULL}}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
834
2bd25c5a 835\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 836
2bd25c5a 837\func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
2569938d 838
2bd25c5a
VZ
839This function splits a full file name into components: the volume (with the
840first version) path (including the volume in the second version), the base name
841and the extension. Any of the output parameters ({\it volume}, {\it path},
842{\it name} or {\it ext}) may be {\tt NULL} if you are not interested in the
843value of a particular component. Also, {\it fullpath} may be empty on entry.
844
845On return, {\it path} contains the file path (without the trailing separator),
846{\it name} contains the file name and {\it ext} contains the file extension
847without leading dot. All three of them may be empty if the corresponding
848component is. The old contents of the strings pointed to by these parameters
849will be overwritten in any case (if the pointers are not {\tt NULL}).
2569938d 850
dfecbee5
VZ
851Note that for a filename ``foo.'' the extension is present, as indicated by the
852trailing dot, but empty. If you need to cope with such cases, you should use
853\arg{hasExt} instead of relying on testing whether \arg{ext} is empty or not.
854
5bb9aeb2 855
f1e77933
VZ
856\membersection{wxFileName::SplitVolume}\label{wxfilenamesplitvolume}
857
858\func{static void}{SplitVolume}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
859
860Splits the given \arg{fullpath} into the volume part (which may be empty) and
861the pure path part, not containing any volume.
862
863\wxheading{See also}
864
865\helpref{SplitPath}{wxfilenamesplitpath}
866
867
2569938d
VZ
868\membersection{wxFileName::Touch}\label{wxfilenametouch}
869
870\func{bool}{Touch}{\void}
871
95c00185 872Sets the access and modification times to the current moment.
2569938d 873
5bb9aeb2 874
2569938d
VZ
875\membersection{wxFileName::operator=}\label{wxfilenameoperatorassign}
876
877\func{wxFileName\& operator}{operator=}{\param{const wxFileName\& }{filename}}
878
2569938d
VZ
879\func{wxFileName\& operator}{operator=}{\param{const wxString\& }{filename}}
880
6f91bc33 881Assigns the new value to this filename object.
2569938d 882
5bb9aeb2 883
2569938d
VZ
884\membersection{wxFileName::operator==}\label{wxfilenameoperatorequal}
885
2b5f62a0 886\constfunc{bool operator}{operator==}{\param{const wxFileName\& }{filename}}
2569938d 887
2b5f62a0 888\constfunc{bool operator}{operator==}{\param{const wxString\& }{filename}}
2569938d 889
0894707e 890Returns {\tt true} if the filenames are equal. The string {\it filenames} is
2b5f62a0
VZ
891interpreted as a path in the native filename format.
892
5bb9aeb2 893
2b5f62a0
VZ
894\membersection{wxFileName::operator!=}\label{wxfilenameoperatornotequal}
895
896\constfunc{bool operator}{operator!=}{\param{const wxFileName\& }{filename}}
897
898\constfunc{bool operator}{operator!=}{\param{const wxString\& }{filename}}
899
0894707e 900Returns {\tt true} if the filenames are different. The string {\it filenames}
2b5f62a0 901is interpreted as a path in the native filename format.
6f91bc33 902