]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/filename.tex
Fixed some label errors
[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
9%% License: wxWindows license
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
17functions (and \helpref{wxWindows functions}{filefunctions} wrapping them).
18Second, it includes the functions for working with the files itself. Note that
19to change the file data you should use \helpref{wxFile}{wxfile} class instead,
20wxFileName provides functions for working with the file attributes.
21
22\wxheading{Derived from}
23
24No base class
25
26\wxheading{Data structures}
27
28Many 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
30current platform.
31
32The path format affects the operation of wxFileName functions in several ways:
33first and foremost, it defines the path separator character to use, but it also
34affects other things such as whether the path has the drive part or not.
35
36\begin{verbatim}
37enum 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
51The kind of normalization to do with the file name: these values can be
52or'd together to perform several operations at once in\rtfsp
53\helpref{Normalize}{wxfilenamenormalize}.
54
55\begin{verbatim}
56enum 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
72wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS
73and VMS formats. Although these formats are quite different, wxFileName tries
74to treat them all in the sam generic way. It supposes that all file names
75consist of the following parts: the volume (also known as drive under Windows
76or device under VMS), the path which is a sequence of directory names separated
77by the \helpref{path separators}{wxfilenamegetpathseparators} and the full
78filename itself which, in turn, is composed from the base file name and the
79extension. All of the individual components of the file name may be empty and,
80for example, the volume name is always empty under Unix, but if they are all
81empty simultaneously, the filename object is considered to be in an invalid
82state and \helpref{IsOk}{wxfilenameisok} returns {\tt FALSE} for it.
83
84File names can be case-sensitive or not, the function\rtfsp
85\helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this.
86
87The rules for determining if the file name is absolute or relative also depends
88on the file name format and the only portable way to answer to this question is
89to use \helpref{IsAbsolute}{wxfilenameisabsolute} method. To ensure that the
90filename is absolute you may use \helpref{Normalize}{wxfilenamenormalize}.
91
92Other functions returning information about the file format provided by this
93class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp
94\helpref{IsPathSeparator}{wxfilenameispathseparator} and\rtfsp
95\helpref{IsWild}{wxfilenameiswild}.
96
97\helpref{IsRelative}{wxfilenameisrelative}
98
99\membersection{File name construction}
100
101TODO.
102
103\membersection{File tests}
104
105Before doing the other tests you should use \helpref{IsOk}{wxfilenameisok} to
106verify that the filename is well defined. If it is,
107\helpref{FileExists}{wxfilenamefileexists} can be used to test if a file with
108such name exists and \helpref{DirExists}{wxfilenamedirexists} - if a directory
109with this name exists.
110
111File names should be compared using \helpref{SameAs}{wxfilenamesameas} method
112or \helpref{$==$}{wxfilenameoperatorequal}.
113
114\membersection{File name components}
115
116These functions allow to examine and modify the directories of the path:
117
118\helpref{AppendDir}{wxfilenameappenddir}\\
119\helpref{InsertDir}{wxfilenameinsertdir}\\
120\helpref{GetDirCount}{wxfilenamegetdircount}
121\helpref{PrependDir}{wxfilenameprependdir}\\
122\helpref{RemoveDir}{wxfilenameremovedir}
123
124To change the components of the file name individually you can use the
125following functions:
126
127\helpref{GetExt}{wxfilenamegetext}\\
128\helpref{GetName}{wxfilenamegetname}\\
129\helpref{GetVolume}{wxfilenamegetvolume}\\
130\helpref{HasExt}{wxfilenamehasext}\\
131\helpref{HasName}{wxfilenamehasname}\\
132\helpref{HasVolume}{wxfilenamehasvolume}\\
133\helpref{SetExt}{wxfilenamesetext}\\
134\helpref{SetName}{wxfilenamesetname}\\
135\helpref{SetVolume}{wxfilenamesetvolume}\\
136
137\membersection{Operations}
138
139These methods allow to work with the file creation, access and modification
140times:
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
6f91bc33 154\membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename}
2569938d
VZ
155
156\func{}{wxFileName}{\void}
157
158Default constructor.
159
2569938d
VZ
160\func{}{wxFileName}{\param{const wxFileName\& }{filename}}
161
162Copy constructor.
163
2569938d
VZ
164\func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
165
6f91bc33 166From a full filename: if it terminates with a '/', a directory path
2569938d
VZ
167is contructed (the name will be empty), otherwise a file name and
168extension are extracted from it
169
2569938d
VZ
170\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
171
6f91bc33 172Constructor from a directory name and a file name.
2569938d
VZ
173
174\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
175
6f91bc33 176Constructor from a directory name, file base name and extension
2569938d
VZ
177
178\membersection{wxFileName::AppendDir}\label{wxfilenameappenddir}
179
180\func{void}{AppendDir}{\param{const wxString\& }{dir}}
181
182
183\membersection{wxFileName::Assign}\label{wxfilenameassign}
184
185\func{void}{Assign}{\param{const wxFileName\& }{filepath}}
186
2569938d
VZ
187\func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
188
2569938d
VZ
189\func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
190
2569938d
VZ
191\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
192
2569938d
VZ
193\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
194
195
196\membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd}
197
6f91bc33
VZ
198\func{void}{AssignCwd}{\param{const wxString\& }{volume = ""}}
199
200Makes this object refer to the current working directory on the specified
201volume (or current volume if {\it volume} is empty).
2569938d 202
6f91bc33 203\wxheading{See also}
2569938d 204
6f91bc33 205\helpref{GetCwd}{wxfilenamegetcwd}
2569938d
VZ
206
207\membersection{wxFileName::AssignDir}\label{wxfilenameassigndir}
208
209\func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
210
211empty volume
212
213
214\membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir}
215
216\func{void}{AssignHomeDir}{\void}
217
218get the value of user home (Unix only mainly)
219
220
221\membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename}
222
223\func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}}
224
ade35f11
VZ
225The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to
226create a temporary file and sets this object to the name of the file. If a
227temporary file couldn't be created, the object is put into the\rtfsp
228\helpref{invalid}{wxfilenameisok} state.
2569938d
VZ
229
230\membersection{wxFileName::Clear}\label{wxfilenameclear}
231
232\func{void}{Clear}{\void}
233
ade35f11
VZ
234Reset all components to default, uninitialized state.
235
02a3b391 236\membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename}
ade35f11
VZ
237
238\func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}}
239
240Returns a temporary file name starting with the given {\it prefix}. If
241the {\it prefix} is an absolute path, the temporary file is created in this
242directory, otherwise it is created in the default system directory for the
243temporary files or in the current directory.
2569938d 244
ade35f11
VZ
245If the function succeeds, the temporary file is actually created (but not
246opened) as well. Under Unix, it will have read and write permissions for the
247owner only.
248
249\wxheading{Return value}
250
251The full temporary file name or an empty string on error.
2569938d
VZ
252
253\membersection{wxFileName::DirExists}\label{wxfilenamedirexists}
254
255\func{bool}{DirExists}{\void}
256
2569938d
VZ
257\func{bool}{DirExists}{\param{const wxString\& }{dir}}
258
02a3b391 259Does the directory with this name exists?
2569938d
VZ
260
261\membersection{wxFileName::DirName}\label{wxfilenamedirname}
262
263\func{wxFileName}{DirName}{\param{const wxString\& }{dir}}
264
2569938d
VZ
265\membersection{wxFileName::FileExists}\label{wxfilenamefileexists}
266
267\func{bool}{FileExists}{\void}
268
2569938d
VZ
269\func{bool}{FileExists}{\param{const wxString\& }{file}}
270
02a3b391 271Does the file with this name exists?
2569938d
VZ
272
273\membersection{wxFileName::FileName}\label{wxfilenamefilename}
274
275\func{wxFileName}{FileName}{\param{const wxString\& }{file}}
276
277static pseudo constructors
278
2569938d
VZ
279\membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd}
280
6f91bc33
VZ
281\func{wxString}{GetCwd}{\param{const wxString\& }{volume = ""}}
282
283Retrieve the value of the current working directory on the specified volume. If
284the volume is empty, the programs current working directory is returned for the
285current volume.
286
287\wxheading{Return value}
288
289The string containing the current working directory or an empty string on
290error.
2569938d 291
6f91bc33
VZ
292\wxheading{See also}
293
294\helpref{AssignCwd}{wxfilenameassigncwd}
2569938d
VZ
295
296\membersection{wxFileName::GetDirCount}\label{wxfilenamegetdircount}
297
298\constfunc{size\_t}{GetDirCount}{\void}
299
300
301\membersection{wxFileName::GetDirs}\label{wxfilenamegetdirs}
302
303\constfunc{const wxArrayString\&}{GetDirs}{\void}
304
305
306\membersection{wxFileName::GetExt}\label{wxfilenamegetext}
307
308\constfunc{wxString}{GetExt}{\void}
309
310
311\membersection{wxFileName::GetFormat}\label{wxfilenamegetformat}
312
313\func{wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
314
315various helpers
316get the canonical path format for this platform
317
318
319\membersection{wxFileName::GetFullName}\label{wxfilenamegetfullname}
320
321\constfunc{wxString}{GetFullName}{\void}
322
323
324\membersection{wxFileName::GetFullPath}\label{wxfilenamegetfullpath}
325
326\constfunc{wxString}{GetFullPath}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
327
328add separator Construct full path with name and ext
329
330
331\membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir}
332
333\func{wxString}{GetHomeDir}{\void}
334
335
336\membersection{wxFileName::GetLongPath}\label{wxfilenamegetlongpath}
337
338\constfunc{wxString}{GetLongPath}{\void}
339
340Return the long form of the path (returns identity on non-Windows platforms)
341
342
343\membersection{wxFileName::GetModificationTime}\label{wxfilenamegetmodificationtime}
344
345\constfunc{wxDateTime}{GetModificationTime}{\void}
346
347convenience wrapper: get just the last mod time of the file
348
349
350\membersection{wxFileName::GetName}\label{wxfilenamegetname}
351
352\constfunc{wxString}{GetName}{\void}
353
354
355\membersection{wxFileName::GetPath}\label{wxfilenamegetpath}
356
357\constfunc{wxString}{GetPath}{\param{bool }{add\_separator = FALSE}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
358
359Construct path only - possibly with the trailing separator
360
361
362\membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators}
363
364\func{wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
365
366get the string of path separators for this format
367
368
369\membersection{wxFileName::GetPathWithSep}\label{wxfilenamegetpathwithsep}
370
371\constfunc{wxString}{GetPathWithSep}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
372
373more readable synonym
374
375
376\membersection{wxFileName::GetShortPath}\label{wxfilenamegetshortpath}
377
378\constfunc{wxString}{GetShortPath}{\void}
379
380Return the short form of the path (returns identity on non-Windows platforms)
381
382
383\membersection{wxFileName::GetTimes}\label{wxfilenamegettimes}
384
385\constfunc{bool}{GetTimes}{\param{wxDateTime* }{dtAccess}, \param{wxDateTime* }{dtMod}, \param{wxDateTime* }{dtChange}}
386
387return the last access, last modification and last change times
388(any of the pointers may be NULL)
389
390
391\membersection{wxFileName::GetVolume}\label{wxfilenamegetvolume}
392
393\constfunc{wxString}{GetVolume}{\void}
394
395
396\membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator}
397
398\func{wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
399
400get the string separating the volume from the path for this format
401
402
403\membersection{wxFileName::HasExt}\label{wxfilenamehasext}
404
405\constfunc{bool}{HasExt}{\void}
406
407
408\membersection{wxFileName::HasName}\label{wxfilenamehasname}
409
410\constfunc{bool}{HasName}{\void}
411
412
413\membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume}
414
415\constfunc{bool}{HasVolume}{\void}
416
417
418\membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir}
419
420\func{void}{InsertDir}{\param{int }{before}, \param{const wxString\& }{dir}}
421
422
423\membersection{wxFileName::IsAbsolute}\label{wxfilenameisabsolute}
424
425\func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
426
427is this filename absolute?
428
429
430\membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive}
431
432\func{bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
433
434Tests
435are the file names of this type cases sensitive?
436
437
438\membersection{wxFileName::IsOk}\label{wxfilenameisok}
439
440\constfunc{bool}{IsOk}{\void}
441
ade35f11
VZ
442Returns {\tt TRUE} if the filename is valid, {\tt FALSE} if it is not
443initialized yet. The assignment functions and
444\helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized,
445invalid state (the former only do it on failure).
2569938d
VZ
446
447\membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator}
448
449\func{bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
450
451is the char a path separator for this format?
452
453
454\membersection{wxFileName::IsRelative}\label{wxfilenameisrelative}
455
456\func{bool}{IsRelative}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
457
458is this filename relative?
459
460
461\membersection{wxFileName::IsWild}\label{wxfilenameiswild}
462
463\func{bool}{IsWild}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
464
465FIXME: what exactly does this do?
466
467
468\membersection{wxFileName::Mkdir}\label{wxfilenamemkdir}
469
470\func{bool}{Mkdir}{\param{int }{perm = 0777}, \param{bool }{full = FALSE}}
471
6f91bc33 472\func{static bool}{Mkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}, \param{bool }{full = FALSE}}
2569938d 473
6f91bc33 474\docparam{dir}{the directory to create}
2569938d 475
6f91bc33
VZ
476\docparam{parm}{the permissions for the newly created directory}
477
478\docparam{full}{if {\tt TRUE}, will try to make each directory in the path}
2569938d 479
6f91bc33 480\wxheading{Return value}
2569938d 481
6f91bc33
VZ
482Returns {\tt TRUE} if the directory was successfully created, {\tt FALSE}
483otherwise.
2569938d
VZ
484
485\membersection{wxFileName::Normalize}\label{wxfilenamenormalize}
486
487\func{bool}{Normalize}{\param{wxPathNormalize }{flags = wxPATH\_NORM\_ALL}, \param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
488
489operations on the path
490normalize the path: with the default flags value, the path will be
491made absolute, without any ".." and "." and all environment
492variables will be expanded in it
493this may be done using another (than current) value of cwd
494
495
496\membersection{wxFileName::PrependDir}\label{wxfilenameprependdir}
497
498\func{void}{PrependDir}{\param{const wxString\& }{dir}}
499
500
501\membersection{wxFileName::RemoveDir}\label{wxfilenameremovedir}
502
503\func{void}{RemoveDir}{\param{int }{pos}}
504
505
506\membersection{wxFileName::Rmdir}\label{wxfilenamermdir}
507
508\func{bool}{Rmdir}{\void}
509
6f91bc33 510\func{static bool}{Rmdir}{\param{const wxString\& }{dir}}
2569938d 511
6f91bc33 512Deletes the specified directory.
2569938d
VZ
513
514
515\membersection{wxFileName::SameAs}\label{wxfilenamesameas}
516
517\func{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
518
6f91bc33 519Compares the filename using the rules of this platform
2569938d
VZ
520
521
522\membersection{wxFileName::SetCwd}\label{wxfilenamesetcwd}
523
524\func{bool}{SetCwd}{\void}
525
6f91bc33 526\func{static bool}{SetCwd}{\param{const wxString\& }{cwd}}
2569938d 527
6f91bc33 528change the current working directory
2569938d
VZ
529
530\membersection{wxFileName::SetExt}\label{wxfilenamesetext}
531
532\func{void}{SetExt}{\param{const wxString\& }{ext}}
533
534
535\membersection{wxFileName::SetFullName}\label{wxfilenamesetfullname}
536
537\func{void}{SetFullName}{\param{const wxString\& }{fullname}}
538
539full name is the file name + extension (but without the path)
540
541
542\membersection{wxFileName::SetName}\label{wxfilenamesetname}
543
544\func{void}{SetName}{\param{const wxString\& }{name}}
545
546
547\membersection{wxFileName::SetTimes}\label{wxfilenamesettimes}
548
549\func{bool}{SetTimes}{\param{const wxDateTime* }{dtCreate}, \param{const wxDateTime* }{dtAccess}, \param{const wxDateTime* }{dtMod}}
550
551set the file creation and last access/mod times
552(any of the pointers may be NULL)
553
554
555\membersection{wxFileName::SetVolume}\label{wxfilenamesetvolume}
556
557\func{void}{SetVolume}{\param{const wxString\& }{volume}}
558
559
560\membersection{wxFileName::SplitPath}\label{wxfilenamesplitpath}
561
562\func{void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
563
564\func{void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
565
566split a fullpath into the volume, path, (base) name and extension
567(all of the pointers can be NULL)
568
569\membersection{wxFileName::Touch}\label{wxfilenametouch}
570
571\func{bool}{Touch}{\void}
572
573set the access and modification times to the current moment
574
575
576\membersection{wxFileName::operator=}\label{wxfilenameoperatorassign}
577
578\func{wxFileName\& operator}{operator=}{\param{const wxFileName\& }{filename}}
579
2569938d
VZ
580\func{wxFileName\& operator}{operator=}{\param{const wxString\& }{filename}}
581
6f91bc33 582Assigns the new value to this filename object.
2569938d
VZ
583
584\membersection{wxFileName::operator==}\label{wxfilenameoperatorequal}
585
586\func{bool operator}{operator==}{\param{const wxFileName\& }{filename}}
587
2569938d
VZ
588\func{bool operator}{operator==}{\param{const wxString\& }{filename}}
589
6f91bc33
VZ
590Returns {\tt TRUE} if the filenames are equal for the native file format.
591