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