1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxFileName documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2001 Vadim Zeitlin
9 %% License: wxWindows 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 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:
27 wxFileName dirname( wxT("C:
\mydir"), wxEmptyString );
28 MyMethod( dirname.GetPath() );
31 The same can be done using the static method
\helpref{wxFileName::DirName
}{wxfilenamedirname
}:
34 wxFileName dirname = wxFileName::DirName( wxT("C:
\mydir") );
35 MyMethod( dirname.GetPath() );
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
}.
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,
54 // get input from user
57 if (wxDirExists(user_input))
58 fname.AssignDir( user_input );
60 fname.Assign( user_input );
63 \wxheading{Derived from
}
67 \wxheading{Include files
}
71 \wxheading{Data structures
}
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
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.
84 wxPATH_NATIVE =
0, // the path format for the current platform
86 wxPATH_BEOS = wxPATH_UNIX,
89 wxPATH_WIN = wxPATH_DOS,
90 wxPATH_OS2 = wxPATH_DOS,
93 wxPATH_MAX // Not a valid value for specifying path format
97 \latexignore{\rtfignore{\wxheading{Function groups
}}}
100 \membersection{File name format
}\label{filenameformat
}
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.
114 File names can be case-sensitive or not, the function
\rtfsp
115 \helpref{IsCaseSensitive
}{wxfilenameiscasesensitive
} allows to determine this.
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.
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.
130 Other functions returning information about the file format provided by this
131 class are
\helpref{GetVolumeSeparator
}{wxfilenamegetvolumeseparator
},
\rtfsp
132 \helpref{IsPathSeparator
}{wxfilenameispathseparator
}.
135 \membersection{File name construction
}\label{filenameconstruction
}
137 You can initialize a wxFileName instance using one of the following functions:
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
}
148 \membersection{File tests
}\label{filetests
}
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.
156 File names should be compared using
\helpref{SameAs
}{wxfilenamesameas
} method
157 or
\helpref{operator $==$
}{wxfilenameoperatorequal
}.
159 For testing basic access modes, you can use:
161 \helpref{IsDirWritable
}{wxfilenameisdirwritable
}\\
162 \helpref{IsDirReadable
}{wxfilenameisdirreadable
}\\
163 \helpref{IsFileWritable
}{wxfilenameisfilewritable
}\\
164 \helpref{IsFileReadable
}{wxfilenameisfilereadable
}\\
165 \helpref{IsFileExecutable
}{wxfilenameisfileexecutable
}
168 \membersection{File name components
}\label{filenamecomponents
}
170 These functions allow to examine and modify the individual directories of the
173 \helpref{AppendDir
}{wxfilenameappenddir
}\\
174 \helpref{InsertDir
}{wxfilenameinsertdir
}\\
175 \helpref{GetDirCount
}{wxfilenamegetdircount
}
176 \helpref{PrependDir
}{wxfilenameprependdir
}\\
177 \helpref{RemoveDir
}{wxfilenameremovedir
}\\
178 \helpref{RemoveLastDir
}{wxfilenameremovelastdir
}
180 To change the components of the file name individually you can use the
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
}\\
196 \membersection{Operations
}\label{filenameoperations
}
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.
204 \helpref{GetModificationTime
}{wxfilenamegetmodificationtime
}\\
205 \helpref{GetTimes
}{wxfilenamegettimes
}\\
206 \helpref{SetTimes
}{wxfilenamesettimes
}\\
207 \helpref{Touch
}{wxfilenametouch
}
209 Other file system operations functions are:
211 \helpref{Mkdir
}{wxfilenamemkdir
}\\
212 \helpref{Rmdir
}{wxfilenamermdir
}
214 \latexignore{\rtfignore{\wxheading{Members
}}}
217 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename
}
219 \func{}{wxFileName
}{\void}
223 \func{}{wxFileName
}{\param{const wxFileName\&
}{filename
}}
227 \func{}{wxFileName
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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.
233 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
235 Constructor from a directory name and a file name.
237 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
239 Constructor from a directory name, base file name and extension.
241 \func{}{wxFileName
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
243 Constructor from a volume name, a directory name, base file name and extension.
246 \membersection{wxFileName::AppendDir
}\label{wxfilenameappenddir
}
248 \func{void
}{AppendDir
}{\param{const wxString\&
}{dir
}}
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).
256 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
258 \func{void
}{Assign
}{\param{const wxFileName\&
}{filepath
}}
260 \func{void
}{Assign
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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}}
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}}
266 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
268 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
270 Creates the file name from various combinations of data.
273 \membersection{wxFileName::AssignCwd
}\label{wxfilenameassigncwd
}
275 \func{static void
}{AssignCwd
}{\param{const wxString\&
}{volume = wxEmptyString
}}
277 Makes this object refer to the current working directory on the specified
278 volume (or current volume if
{\it volume
} is empty).
282 \helpref{GetCwd
}{wxfilenamegetcwd
}
285 \membersection{wxFileName::AssignDir
}\label{wxfilenameassigndir
}
287 \func{void
}{AssignDir
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
289 Sets this file name object to the given directory name. The name and extension
293 \membersection{wxFileName::AssignHomeDir
}\label{wxfilenameassignhomedir
}
295 \func{void
}{AssignHomeDir
}{\void}
297 Sets this file name object to the home directory.
300 \membersection{wxFileName::AssignTempFileName
}\label{wxfilenameassigntempfilename
}
302 \func{void
}{AssignTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
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.
310 \membersection{wxFileName::Clear
}\label{wxfilenameclear
}
312 \func{void
}{Clear
}{\void}
314 Reset all components to default, uninitialized state.
317 \membersection{wxFileName::ClearExt
}\label{wxfilenameclearext
}
319 \func{void
}{SetClearExt
}{\void}
321 Removes the extension from the file name resulting in a
322 file name with no trailing dot.
326 \helpref{SetExt
}{wxfilenamesetext
}
327 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
329 \membersection{wxFileName::CreateTempFileName
}\label{wxfilenamecreatetempfilename
}
331 \func{static wxString
}{CreateTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
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.
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.
345 Under Unix, the temporary file will have read and write permissions for the
346 owner only to minimize the security problems.
348 \wxheading{Parameters
}
350 \docparam{prefix
}{Prefix to use for the temporary file name construction
}
352 \docparam{fileTemp
}{The file to open or
{\tt NULL
} to just get the name
}
354 \wxheading{Return value
}
356 The full temporary file name or an empty string on error.
359 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
361 \constfunc{bool
}{DirExists
}{\void}
363 \func{static bool
}{DirExists
}{\param{const wxString\&
}{dir
}}
365 Returns
{\tt true
} if the directory with this name exists.
368 \membersection{wxFileName::DirName
}\label{wxfilenamedirname
}
370 \func{static wxFileName
}{DirName
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
372 Returns the object corresponding to the directory with the given name.
373 The
{\it dir
} parameter may have trailing path separator or not.
377 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
379 \constfunc{bool
}{FileExists
}{\void}
381 \func{static bool
}{FileExists
}{\param{const wxString\&
}{file
}}
383 Returns
{\tt true
} if the file with this name exists.
387 \helpref{DirExists
}{wxfilenamedirexists
}
391 \membersection{wxFileName::FileName
}\label{wxfilenamefilename
}
393 \func{static wxFileName
}{FileName
}{\param{const wxString\&
}{file
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
395 Returns the file name object corresponding to the given
{\it file
}. This
396 function exists mainly for symmetry with
\helpref{DirName
}{wxfilenamedirname
}.
400 \membersection{wxFileName::GetCwd
}\label{wxfilenamegetcwd
}
402 \func{static wxString
}{GetCwd
}{\param{const wxString\&
}{volume = ""
}}
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
408 \wxheading{Return value
}
410 The string containing the current working directory or an empty string on
415 \helpref{AssignCwd
}{wxfilenameassigncwd
}
418 \membersection{wxFileName::GetDirCount
}\label{wxfilenamegetdircount
}
420 \constfunc{size
\_t}{GetDirCount
}{\void}
422 Returns the number of directories in the file name.
425 \membersection{wxFileName::GetDirs
}\label{wxfilenamegetdirs
}
427 \constfunc{const wxArrayString\&
}{GetDirs
}{\void}
429 Returns the directories in string array form.
432 \membersection{wxFileName::GetExt
}\label{wxfilenamegetext
}
434 \constfunc{wxString
}{GetExt
}{\void}
436 Returns the file name extension.
439 \membersection{wxFileName::GetForbiddenChars
}\label{wxfilenamegetforbiddenchars
}
441 \func{static wxString
}{GetForbiddenChars
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
443 Returns the characters that can't be used in filenames and directory names for the specified format.
446 \membersection{wxFileName::GetFormat
}\label{wxfilenamegetformat
}
448 \func{static wxPathFormat
}{GetFormat
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
450 Returns the canonical path format for this platform.
453 \membersection{wxFileName::GetFullName
}\label{wxfilenamegetfullname
}
455 \constfunc{wxString
}{GetFullName
}{\void}
457 Returns the full name (including extension but excluding directories).
460 \membersection{wxFileName::GetFullPath
}\label{wxfilenamegetfullpath
}
462 \constfunc{wxString
}{GetFullPath
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
464 Returns the full path with name and extension.
467 \membersection{wxFileName::GetHomeDir
}\label{wxfilenamegethomedir
}
469 \func{static wxString
}{GetHomeDir
}{\void}
471 Returns the home directory.
474 \membersection{wxFileName::GetLongPath
}\label{wxfilenamegetlongpath
}
476 \constfunc{wxString
}{GetLongPath
}{\void}
478 Return the long form of the path (returns identity on non-Windows platforms)
481 \membersection{wxFileName::GetModificationTime
}\label{wxfilenamegetmodificationtime
}
483 \constfunc{wxDateTime
}{GetModificationTime
}{\void}
485 Returns the last time the file was last modified.
488 \membersection{wxFileName::GetName
}\label{wxfilenamegetname
}
490 \constfunc{wxString
}{GetName
}{\void}
492 Returns the name part of the filename (without extension).
496 \helpref{GetFullName
}{wxfilenamegetfullname
}
500 \membersection{wxFileName::GetPath
}\label{wxfilenamegetpath
}
502 \constfunc{wxString
}{GetPath
}{\param{int
}{flags =
{\tt wxPATH
\_GET\_VOLUME}},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
504 Returns the path part of the filename (without the name or extension). The
505 possible flags values are:
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
518 \membersection{wxFileName::GetPathSeparator
}\label{wxfilenamegetpathseparator
}
520 \func{static wxChar
}{GetPathSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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
529 \helpref{GetPathSeparators
}{wxfilenamegetpathseparators
}
532 \membersection{wxFileName::GetPathSeparators
}\label{wxfilenamegetpathseparators
}
534 \func{static wxString
}{GetPathSeparators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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
543 \helpref{GetPathSeparator
}{wxfilenamegetpathseparator
}
546 \membersection{wxFileName::GetPathTerminators
}\label{wxfilenamegetpathterminators
}
548 \func{static wxString
}{GetPathTerminators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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.
555 \membersection{wxFileName::GetPathWithSep
}\label{wxfilenamegetpathwithsep
}
557 \constfunc{wxString
}{GetPathWithSep
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
559 Returns the path with the trailing separator, useful for appending the name to
562 This is the same as calling
\helpref{GetPath
}{wxfilenamegetpath
}
563 \texttt{(wxPATH
\_GET\_VOLUME | wxPATH
\_GET\_SEPARATOR, format)
}.
566 \membersection{wxFileName::GetShortPath
}\label{wxfilenamegetshortpath
}
568 \constfunc{wxString
}{GetShortPath
}{\void}
570 Return the short form of the path (returns identity on non-Windows platforms).
573 \membersection{wxFileName::GetSize
}\label{wxfilenamegetsize
}
575 \constfunc{wxULongLong
}{GetSize
}{\void}
577 \func{static wxULongLong
}{GetSize
}{\param{const wxString\&
}{filename
}}
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
}.
584 \membersection{wxFileName::GetHumanReadableSize
}\label{wxfilenamegethumanreadablesize
}
586 \constfunc{wxString
}{GetHumanReadableSize
}{\param{const wxString\&
}{failmsg = "Not available"
},
\param{int
}{precision =
1}}
588 \func{static wxString
}{GetHumanReadableSize
}{\param{const wxULongLong\&
}{bytes
},
\param{const wxString\&
}{nullsize = "Not available"
},
\param{int
}{precision =
1}}
590 Returns the size of this file (first form) or the given number of bytes (second form)
591 in a human-readable form.
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).
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).
600 \membersection{wxFileName::GetTempDir
}\label{wxfilenamegettempdir
}
602 \func{static wxString
}{GetTempDir
}{\void}
604 Returns the directory used for temporary files.
607 \membersection{wxFileName::GetTimes
}\label{wxfilenamegettimes
}
609 \constfunc{bool
}{GetTimes
}{\param{wxDateTime*
}{dtAccess
},
\param{wxDateTime*
}{dtMod
},
\param{wxDateTime*
}{dtCreate
}}
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.
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
}.
625 Any of the pointers may be
{\tt NULL
} if the corresponding time is not
628 \wxheading{Return value
}
630 {\tt true
} on success,
{\tt false
} if we failed to retrieve the times.
633 \membersection{wxFileName::GetVolume
}\label{wxfilenamegetvolume
}
635 \constfunc{wxString
}{GetVolume
}{\void}
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
642 \membersection{wxFileName::GetVolumeSeparator
}\label{wxfilenamegetvolumeseparator
}
644 \func{static wxString
}{GetVolumeSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
646 Returns the string separating the volume from the path for this format.
649 \membersection{wxFileName::HasExt
}\label{wxfilenamehasext
}
651 \constfunc{bool
}{HasExt
}{\void}
653 Returns
{\tt true
} if an extension is present.
656 \membersection{wxFileName::HasName
}\label{wxfilenamehasname
}
658 \constfunc{bool
}{HasName
}{\void}
660 Returns
{\tt true
} if a name is present.
663 \membersection{wxFileName::HasVolume
}\label{wxfilenamehasvolume
}
665 \constfunc{bool
}{HasVolume
}{\void}
667 Returns
{\tt true
} if a volume specifier is present.
670 \membersection{wxFileName::InsertDir
}\label{wxfilenameinsertdir
}
672 \func{void
}{InsertDir
}{\param{size
\_t }{before
},
\param{const wxString\&
}{dir
}}
674 Inserts a directory component before the zero-based position in the directory
675 list. Please see
\helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
678 \membersection{wxFileName::IsAbsolute
}\label{wxfilenameisabsolute
}
680 \func{bool
}{IsAbsolute
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
682 Returns
{\tt true
} if this filename is absolute.
685 \membersection{wxFileName::IsCaseSensitive
}\label{wxfilenameiscasesensitive
}
687 \func{static bool
}{IsCaseSensitive
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
689 Returns
{\tt true
} if the file names of this type are case-sensitive.
692 \membersection{wxFileName::IsDirReadable
}\label{wxfilenameisdirreadable
}
694 \constfunc{bool
}{IsDirReadable
}{\void}
696 \func{static bool
}{IsDirReadable
}{\param{const wxString\&
}{dir
}}
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.
704 \membersection{wxFileName::IsDirWritable
}\label{wxfilenameisdirwritable
}
706 \constfunc{bool
}{IsDirWritable
}{\void}
708 \func{static bool
}{IsDirWritable
}{\param{const wxString\&
}{dir
}}
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.
715 \membersection{wxFileName::IsFileExecutable
}\label{wxfilenameisfileexecutable
}
717 \constfunc{bool
}{IsFileExecutable
}{\void}
719 \func{static bool
}{IsFileExecutable
}{\param{const wxString\&
}{file
}}
721 Returns
{\tt true
} if a file with this name exists and if this process has execute permissions on it.
724 \membersection{wxFileName::IsFileReadable
}\label{wxfilenameisfilereadable
}
726 \constfunc{bool
}{IsFileReadable
}{\void}
728 \func{static bool
}{IsFileReadable
}{\param{const wxString\&
}{file
}}
730 Returns
{\tt true
} if a file with this name exists and if this process has read permissions on it.
733 \membersection{wxFileName::IsFileWritable
}\label{wxfilenameisfilewritable
}
735 \constfunc{bool
}{IsFileWritable
}{\void}
737 \func{static bool
}{IsFileWritable
}{\param{const wxString\&
}{file
}}
739 Returns
{\tt true
} if a file with this name exists and if this process has write permissions on it.
742 \membersection{wxFileName::IsOk
}\label{wxfilenameisok
}
744 \constfunc{bool
}{IsOk
}{\void}
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).
752 \membersection{wxFileName::IsPathSeparator
}\label{wxfilenameispathseparator
}
754 \func{static bool
}{IsPathSeparator
}{\param{wxChar
}{ch
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
756 Returns
{\tt true
} if the char is a path separator for this format.
759 \membersection{wxFileName::IsRelative
}\label{wxfilenameisrelative
}
761 \func{bool
}{IsRelative
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
763 Returns
{\tt true
} if this filename is not absolute.
766 \membersection{wxFileName::IsDir
}\label{wxfilenameisdir
}
768 \constfunc{bool
}{IsDir
}{\void}
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.
776 \membersection{wxFileName::MacFindDefaultTypeAndCreator
}\label{wxfilenamemacfinddefaulttypeandcreator
}
778 \func{static bool
}{MacFindDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32*
}{type
},
\param{wxUint32*
}{creator
}}
780 On Mac OS, gets the common type and creator for the given extension.
782 \membersection{wxFileName::MacRegisterDefaultTypeAndCreator
}\label{wxfilenamemacregisterdefaulttypeandcreator
}
784 \func{static void
}{MacRegisterDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32
}{type
},
\param{wxUint32
}{creator
}}
786 On Mac OS, registers application defined extensions and their default type and creator.
788 \membersection{wxFileName::MacSetDefaultTypeAndCreator
}\label{wxfilenamemacsetdefaulttypeandcreator
}
790 \func{bool
}{MacSetDefaultTypeAndCreator
}{\void}
792 On Mac OS, looks up the appropriate type and creator from the registration and then sets it.
794 \membersection{wxFileName::MakeAbsolute
}\label{wxfilenamemakeabsolute
}
796 \func{bool
}{MakeAbsolute
}{\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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)
}.
803 \helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
},
804 \helpref{Normalize
}{wxfilenamenormalize
},
805 \helpref{IsAbsolute
}{wxfilenameisabsolute
}
808 \membersection{wxFileName::MakeRelativeTo
}\label{wxfilenamemakerelativeto
}
810 \func{bool
}{MakeRelativeTo
}{\param{const wxString\&
}{pathBase = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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
}.
816 \docparam{pathBase
}{the directory to use as root, current directory is used by
819 \docparam{format
}{the file name format, native by default
}
821 \wxheading{Return value
}
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
}).
829 \helpref{Normalize
}{wxfilenamenormalize
}
832 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
834 \func{bool
}{Mkdir
}{\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
836 \func{static bool
}{Mkdir
}{\param{const wxString\&
}{dir
},
\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
838 \docparam{dir
}{the directory to create
}
840 \docparam{parm
}{the permissions for the newly created directory
}
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.
}
846 \wxheading{Return value
}
848 Returns
{\tt true
} if the directory was successfully created,
{\tt false
}
852 \membersection{wxFileName::Normalize
}\label{wxfilenamenormalize
}
854 \func{bool
}{Normalize
}{\param{int
}{flags = wxPATH
\_NORM\_ALL},
\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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.
860 \docparam{flags
}{The kind of normalization to do with the file name. It can be
861 any or-combination of the following constants:
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}}
875 \docparam{cwd
}{If not empty, this directory will be used instead of current
876 working directory in normalization (see wxPATH
\_NORM\_ABSOLUTE).
}
878 \docparam{format
}{The file name format to use when processing the paths, native by default.
}
881 \wxheading{Return value
}
883 \true if normalization was successfully or
\false otherwise.
886 \membersection{wxFileName::PrependDir
}\label{wxfilenameprependdir
}
888 \func{void
}{PrependDir
}{\param{const wxString\&
}{dir
}}
890 Prepends a directory to the file path. Please see
891 \helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
895 \membersection{wxFileName::RemoveDir
}\label{wxfilenameremovedir
}
897 \func{void
}{RemoveDir
}{\param{size
\_t }{pos
}}
899 Removes the specified directory component from the path.
903 \helpref{GetDirCount
}{wxfilenamegetdircount
}
906 \membersection{wxFileName::RemoveLastDir
}\label{wxfilenameremovelastdir
}
908 \func{void
}{RemoveLastDir
}{\void}
910 Removes last directory component from the path.
913 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
915 \func{bool
}{Rmdir
}{\void}
917 \func{static bool
}{Rmdir
}{\param{const wxString\&
}{dir
}}
919 Deletes the specified directory from the file system.
922 \membersection{wxFileName::SameAs
}\label{wxfilenamesameas
}
924 \constfunc{bool
}{SameAs
}{\param{const wxFileName\&
}{filepath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
926 Compares the filename using the rules of this platform.
929 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
931 \func{bool
}{SetCwd
}{\void}
933 \func{static bool
}{SetCwd
}{\param{const wxString\&
}{cwd
}}
935 Changes the current working directory.
938 \membersection{wxFileName::SetExt
}\label{wxfilenamesetext
}
940 \func{void
}{SetExt
}{\param{const wxString\&
}{ext
}}
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
}.
949 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
950 \helpref{ClearExt
}{wxfilenameclearext
}
952 \membersection{wxFileName::SetEmptyExt
}\label{wxfilenamesetemptyext
}
954 \func{void
}{SetEmptyExt
}{\void}
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.
962 \helpref{SetExt
}{wxfilenamesetext
}
963 \helpref{ClearExt
}{wxfilenameclearext
}
965 \membersection{wxFileName::SetFullName
}\label{wxfilenamesetfullname
}
967 \func{void
}{SetFullName
}{\param{const wxString\&
}{fullname
}}
969 The full name is the file name and extension (but without the path).
972 \membersection{wxFileName::SetName
}\label{wxfilenamesetname
}
974 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
976 Sets the name part (without extension).
980 \helpref{SetFullName
}{wxfilenamesetfullname
}
983 \membersection{wxFileName::SetTimes
}\label{wxfilenamesettimes
}
985 \func{bool
}{SetTimes
}{\param{const wxDateTime*
}{dtAccess
},
\param{const wxDateTime*
}{dtMod
},
\param{const wxDateTime*
}{dtCreate
}}
987 Sets the file creation and last access/modification times (any of the pointers may be NULL).
990 \membersection{wxFileName::SetVolume
}\label{wxfilenamesetvolume
}
992 \func{void
}{SetVolume
}{\param{const wxString\&
}{volume
}}
994 Sets the volume specifier.
997 \membersection{wxFileName::SplitPath
}\label{wxfilenamesplitpath
}
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}}
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}}
1003 \func{static void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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.
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
}).
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.
1022 \membersection{wxFileName::SplitVolume
}\label{wxfilenamesplitvolume
}
1024 \func{static void
}{SplitVolume
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{volume
},
\param{wxString*
}{path
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
1026 Splits the given
\arg{fullpath
} into the volume part (which may be empty) and
1027 the pure path part, not containing any volume.
1029 \wxheading{See also
}
1031 \helpref{SplitPath
}{wxfilenamesplitpath
}
1034 \membersection{wxFileName::Touch
}\label{wxfilenametouch
}
1036 \func{bool
}{Touch
}{\void}
1038 Sets the access and modification times to the current moment.
1041 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
1043 \func{wxFileName\& operator
}{operator=
}{\param{const wxFileName\&
}{filename
}}
1045 \func{wxFileName\& operator
}{operator=
}{\param{const wxString\&
}{filename
}}
1047 Assigns the new value to this filename object.
1050 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
1052 \constfunc{bool operator
}{operator==
}{\param{const wxFileName\&
}{filename
}}
1054 \constfunc{bool operator
}{operator==
}{\param{const wxString\&
}{filename
}}
1056 Returns
{\tt true
} if the filenames are equal. The string
{\it filenames
} is
1057 interpreted as a path in the native filename format.
1060 \membersection{wxFileName::operator!=
}\label{wxfilenameoperatornotequal
}
1062 \constfunc{bool operator
}{operator!=
}{\param{const wxFileName\&
}{filename
}}
1064 \constfunc{bool operator
}{operator!=
}{\param{const wxString\&
}{filename
}}
1066 Returns
{\tt true
} if the filenames are different. The string
{\it filenames
}
1067 is interpreted as a path in the native filename format.