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