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