1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxFileName documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2001 Vadim Zeitlin
9 %% License: wxWidgets license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxFileName
}}\label{wxfilename
}
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.
22 \wxheading{Derived from
}
26 \wxheading{Include files
}
30 \wxheading{Data structures
}
32 Many wxFileName methods accept the path format argument which is by
\rtfsp
33 {\tt wxPATH
\_NATIVE} by default meaning to use the path format native for the
36 The path format affects the operation of wxFileName functions in several ways:
37 first and foremost, it defines the path separator character to use, but it also
38 affects other things such as whether the path has the drive part or not.
43 wxPATH_NATIVE =
0, // the path format for the current platform
45 wxPATH_BEOS = wxPATH_UNIX,
48 wxPATH_WIN = wxPATH_DOS,
49 wxPATH_OS2 = wxPATH_DOS,
52 wxPATH_MAX // Not a valid value for specifying path format
56 \latexignore{\rtfignore{\wxheading{Function groups
}}}
59 \membersection{File name format
}\label{filenameformat
}
61 wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS
62 and VMS formats. Although these formats are quite different, wxFileName tries
63 to treat them all in the same generic way. It supposes that all file names
64 consist of the following parts: the volume (also known as drive under Windows
65 or device under VMS), the path which is a sequence of directory names separated
66 by the
\helpref{path separators
}{wxfilenamegetpathseparators
} and the full
67 filename itself which, in turn, is composed from the base file name and the
68 extension. All of the individual components of the file name may be empty and,
69 for example, the volume name is always empty under Unix, but if they are all
70 empty simultaneously, the filename object is considered to be in an invalid
71 state and
\helpref{IsOk
}{wxfilenameisok
} returns
{\tt false
} for it.
73 File names can be case-sensitive or not, the function
\rtfsp
74 \helpref{IsCaseSensitive
}{wxfilenameiscasesensitive
} allows to determine this.
76 The rules for determining if the file name is absolute or relative also depends
77 on the file name format and the only portable way to answer to this question is
78 to use
\helpref{IsAbsolute
}{wxfilenameisabsolute
} method. To ensure that the
79 filename is absolute you may use
\helpref{MakeAbsolute
}{wxfilenamemakeabsolute
}.
80 There is also an inverse function
81 \helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
} which undoes what
82 \helpref{Normalize(wxPATH
\_NORM\_DOTS)
}{wxfilenamenormalize
} does.
84 Other functions returning information about the file format provided by this
85 class are
\helpref{GetVolumeSeparator
}{wxfilenamegetvolumeseparator
},
\rtfsp
86 \helpref{IsPathSeparator
}{wxfilenameispathseparator
}.
88 \helpref{IsRelative
}{wxfilenameisrelative
}
91 \membersection{File name construction
}\label{filenameconstruction
}
96 \membersection{File tests
}\label{filetests
}
98 Before doing the other tests you should use
\helpref{IsOk
}{wxfilenameisok
} to
99 verify that the filename is well defined. If it is,
100 \helpref{FileExists
}{wxfilenamefileexists
} can be used to test if a file with
101 such name exists and
\helpref{DirExists
}{wxfilenamedirexists
} - if a directory
102 with this name exists.
104 File names should be compared using
\helpref{SameAs
}{wxfilenamesameas
} method
105 or
\helpref{$==$
}{wxfilenameoperatorequal
}.
108 \membersection{File name components
}\label{filenamecomponents
}
110 These functions allow to examine and modify the individual directories of the
113 \helpref{AppendDir
}{wxfilenameappenddir
}\\
114 \helpref{InsertDir
}{wxfilenameinsertdir
}\\
115 \helpref{GetDirCount
}{wxfilenamegetdircount
}
116 \helpref{PrependDir
}{wxfilenameprependdir
}\\
117 \helpref{RemoveDir
}{wxfilenameremovedir
}\\
118 \helpref{RemoveLastDir
}{wxfilenameremovelastdir
}
120 To change the components of the file name individually you can use the
123 \helpref{GetExt
}{wxfilenamegetext
}\\
124 \helpref{GetName
}{wxfilenamegetname
}\\
125 \helpref{GetVolume
}{wxfilenamegetvolume
}\\
126 \helpref{HasExt
}{wxfilenamehasext
}\\
127 \helpref{HasName
}{wxfilenamehasname
}\\
128 \helpref{HasVolume
}{wxfilenamehasvolume
}\\
129 \helpref{SetExt
}{wxfilenamesetext
}\\
130 \helpref{SetName
}{wxfilenamesetname
}\\
131 \helpref{SetVolume
}{wxfilenamesetvolume
}\\
134 \membersection{Operations
}\label{filenameoperations
}
136 These methods allow to work with the file creation, access and modification
137 times. Note that not all filesystems under all platforms implement these times
138 in the same way. For example, the access time under Windows has a resolution of
139 one day (so it is really the access date and not time). The access time may be
140 updated when the file is executed or not depending on the platform.
142 \helpref{GetModificationTime
}{wxfilenamegetmodificationtime
}\\
143 \helpref{GetTimes
}{wxfilenamegettimes
}\\
144 \helpref{SetTimes
}{wxfilenamesettimes
}\\
145 \helpref{Touch
}{wxfilenametouch
}
147 Other file system operations functions are:
149 \helpref{Mkdir
}{wxfilenamemkdir
}\\
150 \helpref{Rmdir
}{wxfilenamermdir
}
152 \latexignore{\rtfignore{\wxheading{Members
}}}
155 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename
}
157 \func{}{wxFileName
}{\void}
161 \func{}{wxFileName
}{\param{const wxFileName\&
}{filename
}}
165 \func{}{wxFileName
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
167 Constructor taking a full filename. If it terminates with a '/', a directory path
168 is constructed (the name will be empty), otherwise a file name and
169 extension are extracted from it.
171 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
173 Constructor from a directory name and a file name.
175 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
177 Constructor from a directory name, base file name and extension.
179 \func{}{wxFileName
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
181 Constructor from a volume name, a directory name, base file name and extension.
184 \membersection{wxFileName::AppendDir
}\label{wxfilenameappenddir
}
186 \func{void
}{AppendDir
}{\param{const wxString\&
}{dir
}}
188 Appends a directory component to the path. This component should contain a
189 single directory name level, i.e. not contain any path or volume separators nor
190 should it be empty, otherwise the function does nothing (and generates an
191 assert failure in debug build).
194 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
196 \func{void
}{Assign
}{\param{const wxFileName\&
}{filepath
}}
198 \func{void
}{Assign
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
200 \func{void
}{Assign
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
202 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
204 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
206 Creates the file name from various combinations of data.
209 \membersection{wxFileName::AssignCwd
}\label{wxfilenameassigncwd
}
211 \func{static void
}{AssignCwd
}{\param{const wxString\&
}{volume = wxEmptyString
}}
213 Makes this object refer to the current working directory on the specified
214 volume (or current volume if
{\it volume
} is empty).
218 \helpref{GetCwd
}{wxfilenamegetcwd
}
221 \membersection{wxFileName::AssignDir
}\label{wxfilenameassigndir
}
223 \func{void
}{AssignDir
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
225 Sets this file name object to the given directory name. The name and extension
229 \membersection{wxFileName::AssignHomeDir
}\label{wxfilenameassignhomedir
}
231 \func{void
}{AssignHomeDir
}{\void}
233 Sets this file name object to the home directory.
236 \membersection{wxFileName::AssignTempFileName
}\label{wxfilenameassigntempfilename
}
238 \func{void
}{AssignTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
240 The function calls
\helpref{CreateTempFileName
}{wxfilenamecreatetempfilename
} to
241 create a temporary file and sets this object to the name of the file. If a
242 temporary file couldn't be created, the object is put into the
\rtfsp
243 \helpref{invalid
}{wxfilenameisok
} state.
246 \membersection{wxFileName::Clear
}\label{wxfilenameclear
}
248 \func{void
}{Clear
}{\void}
250 Reset all components to default, uninitialized state.
253 \membersection{wxFileName::CreateTempFileName
}\label{wxfilenamecreatetempfilename
}
255 \func{static wxString
}{CreateTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
257 Returns a temporary file name starting with the given
{\it prefix
}. If
258 the
{\it prefix
} is an absolute path, the temporary file is created in this
259 directory, otherwise it is created in the default system directory for the
260 temporary files or in the current directory.
262 If the function succeeds, the temporary file is actually created. If
\rtfsp
263 {\it fileTemp
} is not
{\tt NULL
}, this file will be opened using the name of
264 the temporary file. When possible, this is done in an atomic way ensuring that
265 no race condition occurs between the temporary file name generation and opening
266 it which could often lead to security compromise on the multiuser systems.
267 If
{\it fileTemp
} is
{\tt NULL
}, the file is only created, but not opened.
269 Under Unix, the temporary file will have read and write permissions for the
270 owner only to minimize the security problems.
272 \wxheading{Parameters
}
274 \docparam{prefix
}{Prefix to use for the temporary file name construction
}
276 \docparam{fileTemp
}{The file to open or
{\tt NULL
} to just get the name
}
278 \wxheading{Return value
}
280 The full temporary file name or an empty string on error.
283 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
285 \constfunc{bool
}{DirExists
}{\void}
287 \func{static bool
}{DirExists
}{\param{const wxString\&
}{dir
}}
289 Returns
{\tt true
} if the directory with this name exists.
292 \membersection{wxFileName::DirName
}\label{wxfilenamedirname
}
294 \func{static wxFileName
}{DirName
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
296 Returns the object corresponding to the directory with the given name.
297 The
{\it dir
} parameter may have trailing path separator or not.
301 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
303 \constfunc{bool
}{FileExists
}{\void}
305 \func{static bool
}{FileExists
}{\param{const wxString\&
}{file
}}
307 Returns
{\tt true
} if the file with this name exists.
311 \helpref{DirExists
}{wxfilenamedirexists
}
315 \membersection{wxFileName::FileName
}\label{wxfilenamefilename
}
317 \func{static wxFileName
}{FileName
}{\param{const wxString\&
}{file
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
319 Returns the file name object corresponding to the given
{\it file
}. This
320 function exists mainly for symmetry with
\helpref{DirName
}{wxfilenamedirname
}.
324 \membersection{wxFileName::GetCwd
}\label{wxfilenamegetcwd
}
326 \func{static wxString
}{GetCwd
}{\param{const wxString\&
}{volume = ""
}}
328 Retrieves the value of the current working directory on the specified volume. If
329 the volume is empty, the programs current working directory is returned for the
332 \wxheading{Return value
}
334 The string containing the current working directory or an empty string on
339 \helpref{AssignCwd
}{wxfilenameassigncwd
}
342 \membersection{wxFileName::GetDirCount
}\label{wxfilenamegetdircount
}
344 \constfunc{size
\_t}{GetDirCount
}{\void}
346 Returns the number of directories in the file name.
349 \membersection{wxFileName::GetDirs
}\label{wxfilenamegetdirs
}
351 \constfunc{const wxArrayString\&
}{GetDirs
}{\void}
353 Returns the directories in string array form.
356 \membersection{wxFileName::GetExt
}\label{wxfilenamegetext
}
358 \constfunc{wxString
}{GetExt
}{\void}
360 Returns the file name extension.
363 \membersection{wxFileName::GetForbiddenChars
}\label{wxfilenamegetforbiddenchars
}
365 \func{static wxString
}{GetForbiddenChars
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
367 Returns the characters that can't be used in filenames and directory names for the specified format.
370 \membersection{wxFileName::GetFormat
}\label{wxfilenamegetformat
}
372 \func{static wxPathFormat
}{GetFormat
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
374 Returns the canonical path format for this platform.
377 \membersection{wxFileName::GetFullName
}\label{wxfilenamegetfullname
}
379 \constfunc{wxString
}{GetFullName
}{\void}
381 Returns the full name (including extension but excluding directories).
384 \membersection{wxFileName::GetFullPath
}\label{wxfilenamegetfullpath
}
386 \constfunc{wxString
}{GetFullPath
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
388 Returns the full path with name and extension.
391 \membersection{wxFileName::GetHomeDir
}\label{wxfilenamegethomedir
}
393 \func{static wxString
}{GetHomeDir
}{\void}
395 Returns the home directory.
398 \membersection{wxFileName::GetLongPath
}\label{wxfilenamegetlongpath
}
400 \constfunc{wxString
}{GetLongPath
}{\void}
402 Return the long form of the path (returns identity on non-Windows platforms)
405 \membersection{wxFileName::GetModificationTime
}\label{wxfilenamegetmodificationtime
}
407 \constfunc{wxDateTime
}{GetModificationTime
}{\void}
409 Returns the last time the file was last modified.
412 \membersection{wxFileName::GetName
}\label{wxfilenamegetname
}
414 \constfunc{wxString
}{GetName
}{\void}
416 Returns the name part of the filename.
419 \membersection{wxFileName::GetPath
}\label{wxfilenamegetpath
}
421 \constfunc{wxString
}{GetPath
}{\param{int
}{flags =
{\tt wxPATH
\_GET\_VOLUME}},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
423 Returns the path part of the filename (without the name or extension). The
424 possible flags values are:
427 \begin{twocollist
}\itemsep=
0pt
428 \twocolitem{{\bf wxPATH
\_GET\_VOLUME}}{Return the path with the volume (does
429 nothing for the filename formats without volumes), otherwise the path without
430 volume part is returned.
}
431 \twocolitem{{\bf wxPATH
\_GET\_SEPARATOR}}{Return the path with the trailing
432 separator, if this flag is not given there will be no separator at the end of
437 \membersection{wxFileName::GetPathSeparator
}\label{wxfilenamegetpathseparator
}
439 \func{static wxChar
}{GetPathSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
441 Returns the usually used path separator for this format. For all formats but
442 {\tt wxPATH
\_DOS} there is only one path separator anyhow, but for DOS there
443 are two of them and the native one, i.e. the backslash is returned by this
448 \helpref{GetPathSeparators
}{wxfilenamegetpathseparators
}
451 \membersection{wxFileName::GetPathSeparators
}\label{wxfilenamegetpathseparators
}
453 \func{static wxString
}{GetPathSeparators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
455 Returns the string containing all the path separators for this format. For all
456 formats but
{\tt wxPATH
\_DOS} this string contains only one character but for
457 DOS and Windows both
{\tt '/'
} and
{\tt '
\textbackslash'
} may be used as
462 \helpref{GetPathSeparator
}{wxfilenamegetpathseparator
}
465 \membersection{wxFileName::GetPathTerminators
}\label{wxfilenamegetpathterminators
}
467 \func{static wxString
}{GetPathTerminators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
469 Returns the string of characters which may terminate the path part. This is the
470 same as
\helpref{GetPathSeparators
}{wxfilenamegetpathseparators
} except for VMS
471 path format where $
]$ is used at the end of the path part.
474 \membersection{wxFileName::GetShortPath
}\label{wxfilenamegetshortpath
}
476 \constfunc{wxString
}{GetShortPath
}{\void}
478 Return the short form of the path (returns identity on non-Windows platforms).
481 \membersection{wxFileName::GetTimes
}\label{wxfilenamegettimes
}
483 \constfunc{bool
}{GetTimes
}{\param{wxDateTime*
}{dtAccess
},
\param{wxDateTime*
}{dtMod
},
\param{wxDateTime*
}{dtCreate
}}
485 Returns the last access, last modification and creation times. The last access
486 time is updated whenever the file is read or written (or executed in the case
487 of Windows), last modification time is only changed when the file is written
488 to. Finally, the creation time is indeed the time when the file was created
489 under Windows and the inode change time under Unix (as it is impossible to
490 retrieve the real file creation time there anyhow) which can also be changed
491 by many operations after the file creation.
493 Any of the pointers may be
{\tt NULL
} if the corresponding time is not
496 \wxheading{Return value
}
498 {\tt true
} on success,
{\tt false
} if we failed to retrieve the times.
501 \membersection{wxFileName::GetVolume
}\label{wxfilenamegetvolume
}
503 \constfunc{wxString
}{GetVolume
}{\void}
505 Returns the string containing the volume for this file name, empty if it
506 doesn't have one or if the file system doesn't support volumes at all (for
510 \membersection{wxFileName::GetVolumeSeparator
}\label{wxfilenamegetvolumeseparator
}
512 \func{static wxString
}{GetVolumeSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
514 Returns the string separating the volume from the path for this format.
517 \membersection{wxFileName::HasExt
}\label{wxfilenamehasext
}
519 \constfunc{bool
}{HasExt
}{\void}
521 Returns
{\tt true
} if an extension is present.
524 \membersection{wxFileName::HasName
}\label{wxfilenamehasname
}
526 \constfunc{bool
}{HasName
}{\void}
528 Returns
{\tt true
} if a name is present.
531 \membersection{wxFileName::HasVolume
}\label{wxfilenamehasvolume
}
533 \constfunc{bool
}{HasVolume
}{\void}
535 Returns
{\tt true
} if a volume specifier is present.
538 \membersection{wxFileName::InsertDir
}\label{wxfilenameinsertdir
}
540 \func{void
}{InsertDir
}{\param{size
\_t }{before
},
\param{const wxString\&
}{dir
}}
542 Inserts a directory component before the zero-based position in the directory
543 list. Please see
\helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
546 \membersection{wxFileName::IsAbsolute
}\label{wxfilenameisabsolute
}
548 \func{bool
}{IsAbsolute
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
550 Returns
{\tt true
} if this filename is absolute.
553 \membersection{wxFileName::IsCaseSensitive
}\label{wxfilenameiscasesensitive
}
555 \func{static bool
}{IsCaseSensitive
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
557 Returns
{\tt true
} if the file names of this type are case-sensitive.
560 \membersection{wxFileName::IsOk
}\label{wxfilenameisok
}
562 \constfunc{bool
}{IsOk
}{\void}
564 Returns
{\tt true
} if the filename is valid,
{\tt false
} if it is not
565 initialized yet. The assignment functions and
566 \helpref{Clear
}{wxfilenameclear
} may reset the object to the uninitialized,
567 invalid state (the former only do it on failure).
570 \membersection{wxFileName::IsPathSeparator
}\label{wxfilenameispathseparator
}
572 \func{static bool
}{IsPathSeparator
}{\param{wxChar
}{ch
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
574 Returns
{\tt true
} if the char is a path separator for this format.
577 \membersection{wxFileName::IsRelative
}\label{wxfilenameisrelative
}
579 \func{bool
}{IsRelative
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
581 Returns
{\tt true
} if this filename is not absolute.
584 \membersection{wxFileName::IsDir
}\label{wxfilenameisdir
}
586 \constfunc{bool
}{IsDir
}{\void}
588 Returns
{\tt true
} if this object represents a directory,
{\tt false
} otherwise
589 (i.e. if it is a file). Note that this method doesn't test whether the
590 directory or file really exists, you should use
591 \helpref{DirExists
}{wxfilenamedirexists
} or
592 \helpref{FileExists
}{wxfilenamefileexists
} for this.
594 \membersection{wxFileName::MacFindDefaultTypeAndCreator
}\label{wxfilenamemacfinddefaulttypeandcreator
}
596 \func{static bool
}{MacFindDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32*
}{type
},
\param{wxUint32*
}{creator
}}
598 On Mac OS, gets the common type and creator for the given extension.
600 \membersection{wxFileName::MacRegisterDefaultTypeAndCreator
}\label{wxfilenamemacregisterdefaulttypeandcreator
}
602 \func{static void
}{MacRegisterDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32
}{type
},
\param{wxUint32
}{creator
}}
604 On Mac OS, registers application defined extensions and their default type and creator.
606 \membersection{wxFileName::MacSetDefaultTypeAndCreator
}\label{wxfilenamemacsetdefaulttypeandcreator
}
608 \func{bool
}{MacSetDefaultTypeAndCreator
}{\void}
610 On Mac OS, looks up the appropriate type and creator from the registration and then sets it.
612 \membersection{wxFileName::MakeAbsolute
}\label{wxfilenamemakeabsolute
}
614 \func{bool
}{MakeAbsolute
}{\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
616 Make the file name absolute. This is a shortcut for
617 {\tt \helpref{Normalize
}{wxfilenamenormalize
}(wxPATH
\_NORM\_DOTS | wxPATH
\_NORM\_ABSOLUTE | wxPATH
\_NORM\_TILDE, cwd, format)
}.
621 \helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
},
622 \helpref{Normalize
}{wxfilenamenormalize
},
623 \helpref{IsAbsolute
}{wxfilenameisabsolute
}
626 \membersection{wxFileName::MakeRelativeTo
}\label{wxfilenamemakerelativeto
}
628 \func{bool
}{MakeRelativeTo
}{\param{const wxString\&
}{pathBase = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
630 This function tries to put this file name in a form relative to
{\it pathBase
}.
631 In other words, it returns the file name which should be used to access this
632 file if the current directory were
{\it pathBase
}.
634 \docparam{pathBase
}{the directory to use as root, current directory is used by
637 \docparam{format
}{the file name format, native by default
}
639 \wxheading{Return value
}
641 {\tt true
} if the file name has been changed,
{\tt false
} if we failed to do
642 anything with it (currently this only happens if the file name is on a volume
643 different from the volume specified by
{\it pathBase
}).
647 \helpref{Normalize
}{wxfilenamenormalize
}
650 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
652 \func{bool
}{Mkdir
}{\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
654 \func{static bool
}{Mkdir
}{\param{const wxString\&
}{dir
},
\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
656 \docparam{dir
}{the directory to create
}
658 \docparam{parm
}{the permissions for the newly created directory
}
660 \docparam{flags
}{if the flags contain
{\tt wxPATH
\_MKDIR\_FULL} flag,
661 try to create each directory in the path and also don't return an error
662 if the target directory already exists.
}
664 \wxheading{Return value
}
666 Returns
{\tt true
} if the directory was successfully created,
{\tt false
}
670 \membersection{wxFileName::Normalize
}\label{wxfilenamenormalize
}
672 \func{bool
}{Normalize
}{\param{int
}{flags = wxPATH
\_NORM\_ALL},
\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
674 Normalize the path. With the default flags value, the path will be
675 made absolute, without any ".." and "." and all environment
676 variables will be expanded in it.
678 \docparam{flags
}{The kind of normalization to do with the file name. It can be
679 any or-combination of the following constants:
682 \twocolitem{{\bf wxPATH
\_NORM\_ENV\_VARS}}{replace env vars with their values
}
683 \twocolitem{{\bf wxPATH
\_NORM\_DOTS}}{squeeze all .. and . and prepend cwd
}
684 \twocolitem{{\bf wxPATH
\_NORM\_TILDE}}{Unix only: replace ~ and ~user
}
685 \twocolitem{{\bf wxPATH
\_NORM\_CASE}}{if filesystem is case insensitive, transform to tolower case
}
686 \twocolitem{{\bf wxPATH
\_NORM\_ABSOLUTE}}{make the path absolute
}
687 \twocolitem{{\bf wxPATH
\_NORM\_LONG}}{make the path the long form
}
688 \twocolitem{{\bf wxPATH
\_NORM\_SHORTCUT}}{resolve if it is a shortcut (Windows only)
}
689 \twocolitem{{\bf wxPATH
\_NORM\_ALL}}{all of previous flags except
\texttt{wxPATH
\_NORM\_CASE}}
693 \docparam{cwd
}{If not empty, this directory will be used instead of current
694 working directory in normalization.
}
696 \docparam{format
}{The file name format, native by default.
}
699 \membersection{wxFileName::PrependDir
}\label{wxfilenameprependdir
}
701 \func{void
}{PrependDir
}{\param{const wxString\&
}{dir
}}
703 Prepends a directory to the file path. Please see
704 \helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
708 \membersection{wxFileName::RemoveDir
}\label{wxfilenameremovedir
}
710 \func{void
}{RemoveDir
}{\param{size
\_t }{pos
}}
712 Removes the specified directory component from the path.
716 \helpref{GetDirCount
}{wxfilenamegetdircount
}
719 \membersection{wxFileName::RemoveLastDir
}\label{wxfilenameremovelastdir
}
721 \func{void
}{RemoveLastDir
}{\void}
723 Removes last directory component from the path.
726 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
728 \func{bool
}{Rmdir
}{\void}
730 \func{static bool
}{Rmdir
}{\param{const wxString\&
}{dir
}}
732 Deletes the specified directory from the file system.
735 \membersection{wxFileName::SameAs
}\label{wxfilenamesameas
}
737 \constfunc{bool
}{SameAs
}{\param{const wxFileName\&
}{filepath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
739 Compares the filename using the rules of this platform.
742 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
744 \func{bool
}{SetCwd
}{\void}
746 \func{static bool
}{SetCwd
}{\param{const wxString\&
}{cwd
}}
748 Changes the current working directory.
751 \membersection{wxFileName::SetExt
}\label{wxfilenamesetext
}
753 \func{void
}{SetExt
}{\param{const wxString\&
}{ext
}}
755 Sets the extension of this file name.
758 \membersection{wxFileName::SetFullName
}\label{wxfilenamesetfullname
}
760 \func{void
}{SetFullName
}{\param{const wxString\&
}{fullname
}}
762 The full name is the file name and extension (but without the path).
765 \membersection{wxFileName::SetName
}\label{wxfilenamesetname
}
767 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
772 \membersection{wxFileName::SetTimes
}\label{wxfilenamesettimes
}
774 \func{bool
}{SetTimes
}{\param{const wxDateTime*
}{dtAccess
},
\param{const wxDateTime*
}{dtMod
},
\param{const wxDateTime*
}{dtCreate
}}
776 Sets the file creation and last access/modification times (any of the pointers may be NULL).
779 \membersection{wxFileName::SetVolume
}\label{wxfilenamesetvolume
}
781 \func{void
}{SetVolume
}{\param{const wxString\&
}{volume
}}
783 Sets the volume specifier.
786 \membersection{wxFileName::SplitPath
}\label{wxfilenamesplitpath
}
788 \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}}
790 \func{static void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
792 This function splits a full file name into components: the volume (with the
793 first version) path (including the volume in the second version), the base name
794 and the extension. Any of the output parameters (
{\it volume
},
{\it path
},
795 {\it name
} or
{\it ext
}) may be
{\tt NULL
} if you are not interested in the
796 value of a particular component. Also,
{\it fullpath
} may be empty on entry.
798 On return,
{\it path
} contains the file path (without the trailing separator),
799 {\it name
} contains the file name and
{\it ext
} contains the file extension
800 without leading dot. All three of them may be empty if the corresponding
801 component is. The old contents of the strings pointed to by these parameters
802 will be overwritten in any case (if the pointers are not
{\tt NULL
}).
805 \membersection{wxFileName::SplitVolume
}\label{wxfilenamesplitvolume
}
807 \func{static void
}{SplitVolume
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{volume
},
\param{wxString*
}{path
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
809 Splits the given
\arg{fullpath
} into the volume part (which may be empty) and
810 the pure path part, not containing any volume.
814 \helpref{SplitPath
}{wxfilenamesplitpath
}
817 \membersection{wxFileName::Touch
}\label{wxfilenametouch
}
819 \func{bool
}{Touch
}{\void}
821 Sets the access and modification times to the current moment.
824 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
826 \func{wxFileName\& operator
}{operator=
}{\param{const wxFileName\&
}{filename
}}
828 \func{wxFileName\& operator
}{operator=
}{\param{const wxString\&
}{filename
}}
830 Assigns the new value to this filename object.
833 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
835 \constfunc{bool operator
}{operator==
}{\param{const wxFileName\&
}{filename
}}
837 \constfunc{bool operator
}{operator==
}{\param{const wxString\&
}{filename
}}
839 Returns
{\tt true
} if the filenames are equal. The string
{\it filenames
} is
840 interpreted as a path in the native filename format.
843 \membersection{wxFileName::operator!=
}\label{wxfilenameoperatornotequal
}
845 \constfunc{bool operator
}{operator!=
}{\param{const wxFileName\&
}{filename
}}
847 \constfunc{bool operator
}{operator!=
}{\param{const wxString\&
}{filename
}}
849 Returns
{\tt true
} if the filenames are different. The string
{\it filenames
}
850 is interpreted as a path in the native filename format.