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