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
}
73 \helpref{wxBase
}{librarieslist
}
75 \wxheading{Data structures
}
77 Many 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
81 The path format affects the operation of wxFileName functions in several ways:
82 first and foremost, it defines the path separator character to use, but it also
83 affects other things such as whether the path has the drive part or not.
88 wxPATH_NATIVE =
0, // the path format for the current platform
90 wxPATH_BEOS = wxPATH_UNIX,
93 wxPATH_WIN = wxPATH_DOS,
94 wxPATH_OS2 = wxPATH_DOS,
97 wxPATH_MAX // Not a valid value for specifying path format
101 \latexignore{\rtfignore{\wxheading{Function groups
}}}
104 \membersection{File name format
}\label{filenameformat
}
106 wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS
107 and VMS formats. Although these formats are quite different, wxFileName tries
108 to treat them all in the same generic way. It supposes that all file names
109 consist of the following parts: the volume (also known as drive under Windows
110 or device under VMS), the path which is a sequence of directory names separated
111 by the
\helpref{path separators
}{wxfilenamegetpathseparators
} and the full
112 filename itself which, in turn, is composed from the base file name and the
113 extension. All of the individual components of the file name may be empty and,
114 for example, the volume name is always empty under Unix, but if they are all
115 empty simultaneously, the filename object is considered to be in an invalid
116 state and
\helpref{IsOk
}{wxfilenameisok
} returns
{\tt false
} for it.
118 File names can be case-sensitive or not, the function
\rtfsp
119 \helpref{IsCaseSensitive
}{wxfilenameiscasesensitive
} allows to determine this.
121 The rules for determining whether the file name is absolute or relative also
122 depend on the file name format and the only portable way to answer this
123 question is to use
\helpref{IsAbsolute
}{wxfilenameisabsolute
} or
\rtfsp
124 \helpref{IsRelative
}{wxfilenameisrelative
} method. Note that on Windows, "X:"
125 refers to the current working directory on drive X. Therefore, a wxFileName
126 instance constructed from for example "X:dir/file.ext" treats the portion
127 beyond drive separator as being relative to that directory.
129 To ensure that the filename is absolute, you may use
\rtfsp
130 \helpref{MakeAbsolute
}{wxfilenamemakeabsolute
}. There is also an inverse
131 function
\helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
} which undoes
132 what
\helpref{Normalize(wxPATH
\_NORM\_DOTS)
}{wxfilenamenormalize
} does.
134 Other functions returning information about the file format provided by this
135 class are
\helpref{GetVolumeSeparator
}{wxfilenamegetvolumeseparator
},
\rtfsp
136 \helpref{IsPathSeparator
}{wxfilenameispathseparator
}.
139 \membersection{File name construction
}\label{filenameconstruction
}
141 You can initialize a wxFileName instance using one of the following functions:
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
}
154 \membersection{File tests
}\label{filetests
}
156 Before doing other tests, you should use
\helpref{IsOk
}{wxfilenameisok
} to
157 verify that the filename is well defined. If it is,
\rtfsp
158 \helpref{FileExists
}{wxfilenamefileexists
} can be used to test whether a file
159 with such name exists and
\helpref{DirExists
}{wxfilenamedirexists
} can be used
160 to test for directory existence.
162 File names should be compared using
\helpref{SameAs
}{wxfilenamesameas
} method
163 or
\helpref{operator $==$
}{wxfilenameoperatorequal
}.
165 For testing basic access modes, you can use:
167 \helpref{IsDirWritable
}{wxfilenameisdirwritable
}\\
168 \helpref{IsDirReadable
}{wxfilenameisdirreadable
}\\
169 \helpref{IsFileWritable
}{wxfilenameisfilewritable
}\\
170 \helpref{IsFileReadable
}{wxfilenameisfilereadable
}\\
171 \helpref{IsFileExecutable
}{wxfilenameisfileexecutable
}
174 \membersection{File name components
}\label{filenamecomponents
}
176 These functions allow to examine and modify the individual directories of the
179 \helpref{AppendDir
}{wxfilenameappenddir
}\\
180 \helpref{InsertDir
}{wxfilenameinsertdir
}\\
181 \helpref{GetDirCount
}{wxfilenamegetdircount
}
182 \helpref{PrependDir
}{wxfilenameprependdir
}\\
183 \helpref{RemoveDir
}{wxfilenameremovedir
}\\
184 \helpref{RemoveLastDir
}{wxfilenameremovelastdir
}
186 To change the components of the file name individually you can use the
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
}\\
202 \membersection{Operations
}\label{filenameoperations
}
204 These methods allow to work with the file creation, access and modification
205 times. Note that not all filesystems under all platforms implement these times
206 in the same way. For example, the access time under Windows has a resolution of
207 one day (so it is really the access date and not time). The access time may be
208 updated when the file is executed or not depending on the platform.
210 \helpref{GetModificationTime
}{wxfilenamegetmodificationtime
}\\
211 \helpref{GetTimes
}{wxfilenamegettimes
}\\
212 \helpref{SetTimes
}{wxfilenamesettimes
}\\
213 \helpref{Touch
}{wxfilenametouch
}
215 Other file system operations functions are:
217 \helpref{Mkdir
}{wxfilenamemkdir
}\\
218 \helpref{Rmdir
}{wxfilenamermdir
}
220 \latexignore{\rtfignore{\wxheading{Members
}}}
223 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename
}
225 \func{}{wxFileName
}{\void}
229 \func{}{wxFileName
}{\param{const wxFileName\&
}{filename
}}
233 \func{}{wxFileName
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
235 Constructor taking a full filename. If it terminates with a '/', a directory path
236 is constructed (the name will be empty), otherwise a file name and
237 extension are extracted from it.
239 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
241 Constructor from a directory name and a file name.
243 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
245 Constructor from a directory name, base file name and extension.
247 \func{}{wxFileName
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
249 Constructor from a volume name, a directory name, base file name and extension.
252 \membersection{wxFileName::AppendDir
}\label{wxfilenameappenddir
}
254 \func{void
}{AppendDir
}{\param{const wxString\&
}{dir
}}
256 Appends a directory component to the path. This component should contain a
257 single directory name level, i.e. not contain any path or volume separators nor
258 should it be empty, otherwise the function does nothing (and generates an
259 assert failure in debug build).
262 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
264 \func{void
}{Assign
}{\param{const wxFileName\&
}{filepath
}}
266 \func{void
}{Assign
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
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}}
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}}
272 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
274 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
276 Creates the file name from various combinations of data.
279 \membersection{wxFileName::AssignCwd
}\label{wxfilenameassigncwd
}
281 \func{static void
}{AssignCwd
}{\param{const wxString\&
}{volume = wxEmptyString
}}
283 Makes this object refer to the current working directory on the specified
284 volume (or current volume if
{\it volume
} is empty).
288 \helpref{GetCwd
}{wxfilenamegetcwd
}
291 \membersection{wxFileName::AssignDir
}\label{wxfilenameassigndir
}
293 \func{void
}{AssignDir
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
295 Sets this file name object to the given directory name. The name and extension
299 \membersection{wxFileName::AssignHomeDir
}\label{wxfilenameassignhomedir
}
301 \func{void
}{AssignHomeDir
}{\void}
303 Sets this file name object to the home directory.
306 \membersection{wxFileName::AssignTempFileName
}\label{wxfilenameassigntempfilename
}
308 \func{void
}{AssignTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
310 The function calls
\helpref{CreateTempFileName
}{wxfilenamecreatetempfilename
} to
311 create a temporary file and sets this object to the name of the file. If a
312 temporary file couldn't be created, the object is put into the
\rtfsp
313 \helpref{invalid
}{wxfilenameisok
} state.
316 \membersection{wxFileName::Clear
}\label{wxfilenameclear
}
318 \func{void
}{Clear
}{\void}
320 Reset all components to default, uninitialized state.
323 \membersection{wxFileName::ClearExt
}\label{wxfilenameclearext
}
325 \func{void
}{SetClearExt
}{\void}
327 Removes the extension from the file name resulting in a
328 file name with no trailing dot.
332 \helpref{SetExt
}{wxfilenamesetext
}
333 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
335 \membersection{wxFileName::CreateTempFileName
}\label{wxfilenamecreatetempfilename
}
337 \func{static wxString
}{CreateTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
339 Returns a temporary file name starting with the given
{\it prefix
}. If
340 the
{\it prefix
} is an absolute path, the temporary file is created in this
341 directory, otherwise it is created in the default system directory for the
342 temporary files or in the current directory.
344 If 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
346 the temporary file. When possible, this is done in an atomic way ensuring that
347 no race condition occurs between the temporary file name generation and opening
348 it which could often lead to security compromise on the multiuser systems.
349 If
{\it fileTemp
} is
{\tt NULL
}, the file is only created, but not opened.
351 Under Unix, the temporary file will have read and write permissions for the
352 owner only to minimize the security problems.
354 \wxheading{Parameters
}
356 \docparam{prefix
}{Prefix to use for the temporary file name construction
}
358 \docparam{fileTemp
}{The file to open or
{\tt NULL
} to just get the name
}
360 \wxheading{Return value
}
362 The full temporary file name or an empty string on error.
365 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
367 \constfunc{bool
}{DirExists
}{\void}
369 \func{static bool
}{DirExists
}{\param{const wxString\&
}{dir
}}
371 Returns
{\tt true
} if the directory with this name exists.
374 \membersection{wxFileName::DirName
}\label{wxfilenamedirname
}
376 \func{static wxFileName
}{DirName
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
378 Returns the object corresponding to the directory with the given name.
379 The
{\it dir
} parameter may have trailing path separator or not.
383 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
385 \constfunc{bool
}{FileExists
}{\void}
387 \func{static bool
}{FileExists
}{\param{const wxString\&
}{file
}}
389 Returns
{\tt true
} if the file with this name exists.
393 \helpref{DirExists
}{wxfilenamedirexists
}
397 \membersection{wxFileName::FileName
}\label{wxfilenamefilename
}
399 \func{static wxFileName
}{FileName
}{\param{const wxString\&
}{file
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
401 Returns the file name object corresponding to the given
{\it file
}. This
402 function exists mainly for symmetry with
\helpref{DirName
}{wxfilenamedirname
}.
406 \membersection{wxFileName::GetCwd
}\label{wxfilenamegetcwd
}
408 \func{static wxString
}{GetCwd
}{\param{const wxString\&
}{volume = ""
}}
410 Retrieves the value of the current working directory on the specified volume. If
411 the volume is empty, the program's current working directory is returned for the
414 \wxheading{Return value
}
416 The string containing the current working directory or an empty string on
421 \helpref{AssignCwd
}{wxfilenameassigncwd
}
424 \membersection{wxFileName::GetDirCount
}\label{wxfilenamegetdircount
}
426 \constfunc{size
\_t}{GetDirCount
}{\void}
428 Returns the number of directories in the file name.
431 \membersection{wxFileName::GetDirs
}\label{wxfilenamegetdirs
}
433 \constfunc{const wxArrayString\&
}{GetDirs
}{\void}
435 Returns the directories in string array form.
438 \membersection{wxFileName::GetExt
}\label{wxfilenamegetext
}
440 \constfunc{wxString
}{GetExt
}{\void}
442 Returns the file name extension.
445 \membersection{wxFileName::GetForbiddenChars
}\label{wxfilenamegetforbiddenchars
}
447 \func{static wxString
}{GetForbiddenChars
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
449 Returns the characters that can't be used in filenames and directory names for the specified format.
452 \membersection{wxFileName::GetFormat
}\label{wxfilenamegetformat
}
454 \func{static wxPathFormat
}{GetFormat
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
456 Returns the canonical path format for this platform.
459 \membersection{wxFileName::GetFullName
}\label{wxfilenamegetfullname
}
461 \constfunc{wxString
}{GetFullName
}{\void}
463 Returns the full name (including extension but excluding directories).
466 \membersection{wxFileName::GetFullPath
}\label{wxfilenamegetfullpath
}
468 \constfunc{wxString
}{GetFullPath
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
470 Returns the full path with name and extension.
473 \membersection{wxFileName::GetHomeDir
}\label{wxfilenamegethomedir
}
475 \func{static wxString
}{GetHomeDir
}{\void}
477 Returns the home directory.
480 \membersection{wxFileName::GetLongPath
}\label{wxfilenamegetlongpath
}
482 \constfunc{wxString
}{GetLongPath
}{\void}
484 Return the long form of the path (returns identity on non-Windows platforms)
487 \membersection{wxFileName::GetModificationTime
}\label{wxfilenamegetmodificationtime
}
489 \constfunc{wxDateTime
}{GetModificationTime
}{\void}
491 Returns the last time the file was last modified.
494 \membersection{wxFileName::GetName
}\label{wxfilenamegetname
}
496 \constfunc{wxString
}{GetName
}{\void}
498 Returns the name part of the filename (without extension).
502 \helpref{GetFullName
}{wxfilenamegetfullname
}
506 \membersection{wxFileName::GetPath
}\label{wxfilenamegetpath
}
508 \constfunc{wxString
}{GetPath
}{\param{int
}{flags =
{\tt wxPATH
\_GET\_VOLUME}},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
510 Returns the path part of the filename (without the name or extension). The
511 possible flags values are:
514 \begin{twocollist
}\itemsep=
0pt
515 \twocolitem{{\bf wxPATH
\_GET\_VOLUME}}{Return the path with the volume (does
516 nothing for the filename formats without volumes), otherwise the path without
517 volume part is returned.
}
518 \twocolitem{{\bf wxPATH
\_GET\_SEPARATOR}}{Return the path with the trailing
519 separator, if this flag is not given there will be no separator at the end of
524 \membersection{wxFileName::GetPathSeparator
}\label{wxfilenamegetpathseparator
}
526 \func{static wxChar
}{GetPathSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
528 Returns 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
530 are two of them and the native one, i.e. the backslash is returned by this
535 \helpref{GetPathSeparators
}{wxfilenamegetpathseparators
}
538 \membersection{wxFileName::GetPathSeparators
}\label{wxfilenamegetpathseparators
}
540 \func{static wxString
}{GetPathSeparators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
542 Returns the string containing all the path separators for this format. For all
543 formats but
{\tt wxPATH
\_DOS} this string contains only one character but for
544 DOS and Windows both
{\tt '/'
} and
{\tt '
\textbackslash'
} may be used as
549 \helpref{GetPathSeparator
}{wxfilenamegetpathseparator
}
552 \membersection{wxFileName::GetPathTerminators
}\label{wxfilenamegetpathterminators
}
554 \func{static wxString
}{GetPathTerminators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
556 Returns the string of characters which may terminate the path part. This is the
557 same as
\helpref{GetPathSeparators
}{wxfilenamegetpathseparators
} except for VMS
558 path format where $
]$ is used at the end of the path part.
561 \membersection{wxFileName::GetPathWithSep
}\label{wxfilenamegetpathwithsep
}
563 \constfunc{wxString
}{GetPathWithSep
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
565 Returns the path with the trailing separator, useful for appending the name to
568 This is the same as calling
\helpref{GetPath
}{wxfilenamegetpath
}
569 \texttt{(wxPATH
\_GET\_VOLUME | wxPATH
\_GET\_SEPARATOR, format)
}.
572 \membersection{wxFileName::GetShortPath
}\label{wxfilenamegetshortpath
}
574 \constfunc{wxString
}{GetShortPath
}{\void}
576 Return the short form of the path (returns identity on non-Windows platforms).
579 \membersection{wxFileName::GetSize
}\label{wxfilenamegetsize
}
581 \constfunc{wxULongLong
}{GetSize
}{\void}
583 \func{static wxULongLong
}{GetSize
}{\param{const wxString\&
}{filename
}}
585 Returns the size of this file (first form) or the size of the given file (second form).
586 If the file does not exist or its size could not be read (because e.g. the file is locked
587 by another process) the returned value is
{\tt wxInvalidSize
}.
590 \membersection{wxFileName::GetHumanReadableSize
}\label{wxfilenamegethumanreadablesize
}
592 \constfunc{wxString
}{GetHumanReadableSize
}{\param{const wxString\&
}{failmsg = "Not available"
},
\param{int
}{precision =
1}}
594 \func{static wxString
}{GetHumanReadableSize
}{\param{const wxULongLong\&
}{bytes
},
\param{const wxString\&
}{nullsize = "Not available"
},
\param{int
}{precision =
1}}
596 Returns the size of this file (first form) or the given number of bytes (second form)
597 in a human-readable form.
599 If the size could not be retrieved the
{\tt failmsg
} string is returned (first form).
600 If
{\tt bytes
} is
{\tt wxInvalidSize
} or zero, then
{\tt nullsize
} is returned (second form).
602 In case of success, the returned string is a floating-point number with
{\tt precision
} decimal digits
603 followed by the size unit (B, kB, MB, GB, TB: respectively bytes, kilobytes, megabytes, gigabytes, terabytes).
606 \membersection{wxFileName::GetTempDir
}\label{wxfilenamegettempdir
}
608 \func{static wxString
}{GetTempDir
}{\void}
610 Returns the directory used for temporary files.
613 \membersection{wxFileName::GetTimes
}\label{wxfilenamegettimes
}
615 \constfunc{bool
}{GetTimes
}{\param{wxDateTime*
}{dtAccess
},
\param{wxDateTime*
}{dtMod
},
\param{wxDateTime*
}{dtCreate
}}
617 Returns the last access, last modification and creation times. The last access
618 time is updated whenever the file is read or written (or executed in the case
619 of Windows), last modification time is only changed when the file is written
620 to. Finally, the creation time is indeed the time when the file was created
621 under Windows and the inode change time under Unix (as it is impossible to
622 retrieve the real file creation time there anyhow) which can also be changed
623 by many operations after the file creation.
625 If no filename or extension is specified in this instance of wxFileName
626 (and therefore
\helpref{IsDir
}{wxfilenameisdir
} returns
{\tt true
}) then
627 this function will return the directory times of the path specified by
628 \helpref{GetPath
}{wxfilenamegetpath
}, otherwise the file times of the
629 file specified by
\helpref{GetFullPath
}{wxfilenamegetfullpath
}.
631 Any of the pointers may be
{\tt NULL
} if the corresponding time is not
634 \wxheading{Return value
}
636 {\tt true
} on success,
{\tt false
} if we failed to retrieve the times.
639 \membersection{wxFileName::GetVolume
}\label{wxfilenamegetvolume
}
641 \constfunc{wxString
}{GetVolume
}{\void}
643 Returns the string containing the volume for this file name, empty if it
644 doesn't have one or if the file system doesn't support volumes at all (for
648 \membersection{wxFileName::GetVolumeSeparator
}\label{wxfilenamegetvolumeseparator
}
650 \func{static wxString
}{GetVolumeSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
652 Returns the string separating the volume from the path for this format.
655 \membersection{wxFileName::HasExt
}\label{wxfilenamehasext
}
657 \constfunc{bool
}{HasExt
}{\void}
659 Returns
{\tt true
} if an extension is present.
662 \membersection{wxFileName::HasName
}\label{wxfilenamehasname
}
664 \constfunc{bool
}{HasName
}{\void}
666 Returns
{\tt true
} if a name is present.
669 \membersection{wxFileName::HasVolume
}\label{wxfilenamehasvolume
}
671 \constfunc{bool
}{HasVolume
}{\void}
673 Returns
{\tt true
} if a volume specifier is present.
676 \membersection{wxFileName::InsertDir
}\label{wxfilenameinsertdir
}
678 \func{void
}{InsertDir
}{\param{size
\_t }{before
},
\param{const wxString\&
}{dir
}}
680 Inserts a directory component before the zero-based position in the directory
681 list. Please see
\helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
684 \membersection{wxFileName::IsAbsolute
}\label{wxfilenameisabsolute
}
686 \func{bool
}{IsAbsolute
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
688 Returns
{\tt true
} if this filename is absolute.
691 \membersection{wxFileName::IsCaseSensitive
}\label{wxfilenameiscasesensitive
}
693 \func{static bool
}{IsCaseSensitive
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
695 Returns
{\tt true
} if the file names of this type are case-sensitive.
698 \membersection{wxFileName::IsDirReadable
}\label{wxfilenameisdirreadable
}
700 \constfunc{bool
}{IsDirReadable
}{\void}
702 \func{static bool
}{IsDirReadable
}{\param{const wxString\&
}{dir
}}
704 Returns
{\tt true
} if the directory component of this instance (or given
\arg{dir
})
705 is an existing directory and this process has read permissions on it.
706 Read permissions on a directory mean that you can list the directory contents but it
707 doesn't imply that you have read permissions on the files contained.
710 \membersection{wxFileName::IsDirWritable
}\label{wxfilenameisdirwritable
}
712 \constfunc{bool
}{IsDirWritable
}{\void}
714 \func{static bool
}{IsDirWritable
}{\param{const wxString\&
}{dir
}}
716 Returns
{\tt true
} if the directory component of this instance (or given
\arg{dir
})
717 is an existing directory and this process has write permissions on it.
718 Write permissions on a directory mean that you can create new files in the directory.
721 \membersection{wxFileName::IsFileExecutable
}\label{wxfilenameisfileexecutable
}
723 \constfunc{bool
}{IsFileExecutable
}{\void}
725 \func{static bool
}{IsFileExecutable
}{\param{const wxString\&
}{file
}}
727 Returns
{\tt true
} if a file with this name exists and if this process has execute permissions on it.
730 \membersection{wxFileName::IsFileReadable
}\label{wxfilenameisfilereadable
}
732 \constfunc{bool
}{IsFileReadable
}{\void}
734 \func{static bool
}{IsFileReadable
}{\param{const wxString\&
}{file
}}
736 Returns
{\tt true
} if a file with this name exists and if this process has read permissions on it.
739 \membersection{wxFileName::IsFileWritable
}\label{wxfilenameisfilewritable
}
741 \constfunc{bool
}{IsFileWritable
}{\void}
743 \func{static bool
}{IsFileWritable
}{\param{const wxString\&
}{file
}}
745 Returns
{\tt true
} if a file with this name exists and if this process has write permissions on it.
748 \membersection{wxFileName::IsOk
}\label{wxfilenameisok
}
750 \constfunc{bool
}{IsOk
}{\void}
752 Returns
{\tt true
} if the filename is valid,
{\tt false
} if it is not
753 initialized yet. The assignment functions and
754 \helpref{Clear
}{wxfilenameclear
} may reset the object to the uninitialized,
755 invalid state (the former only do it on failure).
758 \membersection{wxFileName::IsPathSeparator
}\label{wxfilenameispathseparator
}
760 \func{static bool
}{IsPathSeparator
}{\param{wxChar
}{ch
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
762 Returns
{\tt true
} if the char is a path separator for this format.
765 \membersection{wxFileName::IsRelative
}\label{wxfilenameisrelative
}
767 \func{bool
}{IsRelative
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
769 Returns
{\tt true
} if this filename is not absolute.
772 \membersection{wxFileName::IsDir
}\label{wxfilenameisdir
}
774 \constfunc{bool
}{IsDir
}{\void}
776 Returns
{\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
778 directory or file really exists, you should use
779 \helpref{DirExists
}{wxfilenamedirexists
} or
780 \helpref{FileExists
}{wxfilenamefileexists
} for this.
782 \membersection{wxFileName::MacFindDefaultTypeAndCreator
}\label{wxfilenamemacfinddefaulttypeandcreator
}
784 \func{static bool
}{MacFindDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32*
}{type
},
\param{wxUint32*
}{creator
}}
786 On Mac OS, gets the common type and creator for the given extension.
788 \membersection{wxFileName::MacRegisterDefaultTypeAndCreator
}\label{wxfilenamemacregisterdefaulttypeandcreator
}
790 \func{static void
}{MacRegisterDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32
}{type
},
\param{wxUint32
}{creator
}}
792 On Mac OS, registers application defined extensions and their default type and creator.
794 \membersection{wxFileName::MacSetDefaultTypeAndCreator
}\label{wxfilenamemacsetdefaulttypeandcreator
}
796 \func{bool
}{MacSetDefaultTypeAndCreator
}{\void}
798 On Mac OS, looks up the appropriate type and creator from the registration and then sets it.
800 \membersection{wxFileName::MakeAbsolute
}\label{wxfilenamemakeabsolute
}
802 \func{bool
}{MakeAbsolute
}{\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
804 Make 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)
}.
809 \helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
},
810 \helpref{Normalize
}{wxfilenamenormalize
},
811 \helpref{IsAbsolute
}{wxfilenameisabsolute
}
814 \membersection{wxFileName::MakeRelativeTo
}\label{wxfilenamemakerelativeto
}
816 \func{bool
}{MakeRelativeTo
}{\param{const wxString\&
}{pathBase = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
818 This function tries to put this file name in a form relative to
{\it pathBase
}.
819 In other words, it returns the file name which should be used to access this
820 file if the current directory were
{\it pathBase
}.
822 \docparam{pathBase
}{the directory to use as root, current directory is used by
825 \docparam{format
}{the file name format, native by default
}
827 \wxheading{Return value
}
829 {\tt true
} if the file name has been changed,
{\tt false
} if we failed to do
830 anything with it (currently this only happens if the file name is on a volume
831 different from the volume specified by
{\it pathBase
}).
835 \helpref{Normalize
}{wxfilenamenormalize
}
838 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
840 \func{bool
}{Mkdir
}{\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
842 \func{static bool
}{Mkdir
}{\param{const wxString\&
}{dir
},
\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
844 \docparam{dir
}{the directory to create
}
846 \docparam{parm
}{the permissions for the newly created directory
}
848 \docparam{flags
}{if the flags contain
{\tt wxPATH
\_MKDIR\_FULL} flag,
849 try to create each directory in the path and also don't return an error
850 if the target directory already exists.
}
852 \wxheading{Return value
}
854 Returns
{\tt true
} if the directory was successfully created,
{\tt false
}
858 \membersection{wxFileName::Normalize
}\label{wxfilenamenormalize
}
860 \func{bool
}{Normalize
}{\param{int
}{flags = wxPATH
\_NORM\_ALL},
\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
862 Normalize the path. With the default flags value, the path will be
863 made absolute, without any ".." and "." and all environment
864 variables will be expanded in it.
866 \docparam{flags
}{The kind of normalization to do with the file name. It can be
867 any or-combination of the following constants:
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}}
881 \docparam{cwd
}{If not empty, this directory will be used instead of current
882 working directory in normalization (see wxPATH
\_NORM\_ABSOLUTE).
}
884 \docparam{format
}{The file name format to use when processing the paths, native by default.
}
887 \wxheading{Return value
}
889 \true if normalization was successfully or
\false otherwise.
892 \membersection{wxFileName::PrependDir
}\label{wxfilenameprependdir
}
894 \func{void
}{PrependDir
}{\param{const wxString\&
}{dir
}}
896 Prepends a directory to the file path. Please see
897 \helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
901 \membersection{wxFileName::RemoveDir
}\label{wxfilenameremovedir
}
903 \func{void
}{RemoveDir
}{\param{size
\_t }{pos
}}
905 Removes the specified directory component from the path.
909 \helpref{GetDirCount
}{wxfilenamegetdircount
}
912 \membersection{wxFileName::RemoveLastDir
}\label{wxfilenameremovelastdir
}
914 \func{void
}{RemoveLastDir
}{\void}
916 Removes last directory component from the path.
919 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
921 \func{bool
}{Rmdir
}{\void}
923 \func{static bool
}{Rmdir
}{\param{const wxString\&
}{dir
}}
925 Deletes the specified directory from the file system.
928 \membersection{wxFileName::SameAs
}\label{wxfilenamesameas
}
930 \constfunc{bool
}{SameAs
}{\param{const wxFileName\&
}{filepath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
932 Compares the filename using the rules of this platform.
935 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
937 \func{bool
}{SetCwd
}{\void}
939 \func{static bool
}{SetCwd
}{\param{const wxString\&
}{cwd
}}
941 Changes the current working directory.
944 \membersection{wxFileName::SetExt
}\label{wxfilenamesetext
}
946 \func{void
}{SetExt
}{\param{const wxString\&
}{ext
}}
948 Sets the extension of the file name. Setting an empty string
949 as the extension will remove the extension resulting in a file
950 name without a trailing dot, unlike a call to
951 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}.
955 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
956 \helpref{ClearExt
}{wxfilenameclearext
}
958 \membersection{wxFileName::SetEmptyExt
}\label{wxfilenamesetemptyext
}
960 \func{void
}{SetEmptyExt
}{\void}
962 Sets the extension of the file name to be an empty extension.
963 This is different from having no extension at all as the file
964 name will have a trailing dot after a call to this method.
968 \helpref{SetExt
}{wxfilenamesetext
}
969 \helpref{ClearExt
}{wxfilenameclearext
}
971 \membersection{wxFileName::SetFullName
}\label{wxfilenamesetfullname
}
973 \func{void
}{SetFullName
}{\param{const wxString\&
}{fullname
}}
975 The full name is the file name and extension (but without the path).
978 \membersection{wxFileName::SetName
}\label{wxfilenamesetname
}
980 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
982 Sets the name part (without extension).
986 \helpref{SetFullName
}{wxfilenamesetfullname
}
989 \membersection{wxFileName::SetTimes
}\label{wxfilenamesettimes
}
991 \func{bool
}{SetTimes
}{\param{const wxDateTime*
}{dtAccess
},
\param{const wxDateTime*
}{dtMod
},
\param{const wxDateTime*
}{dtCreate
}}
993 Sets the file creation and last access/modification times (any of the pointers may be NULL).
996 \membersection{wxFileName::SetVolume
}\label{wxfilenamesetvolume
}
998 \func{void
}{SetVolume
}{\param{const wxString\&
}{volume
}}
1000 Sets the volume specifier.
1003 \membersection{wxFileName::SplitPath
}\label{wxfilenamesplitpath
}
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}}
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}}
1009 \func{static void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
1011 This function splits a full file name into components: the volume (with the
1012 first version) path (including the volume in the second version), the base name
1013 and 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
1015 value of a particular component. Also,
{\it fullpath
} may be empty on entry.
1017 On 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
1019 without leading dot. All three of them may be empty if the corresponding
1020 component is. The old contents of the strings pointed to by these parameters
1021 will be overwritten in any case (if the pointers are not
{\tt NULL
}).
1023 Note that for a filename ``foo.'' the extension is present, as indicated by the
1024 trailing 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.
1028 \membersection{wxFileName::SplitVolume
}\label{wxfilenamesplitvolume
}
1030 \func{static void
}{SplitVolume
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{volume
},
\param{wxString*
}{path
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
1032 Splits the given
\arg{fullpath
} into the volume part (which may be empty) and
1033 the pure path part, not containing any volume.
1035 \wxheading{See also
}
1037 \helpref{SplitPath
}{wxfilenamesplitpath
}
1040 \membersection{wxFileName::Touch
}\label{wxfilenametouch
}
1042 \func{bool
}{Touch
}{\void}
1044 Sets the access and modification times to the current moment.
1047 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
1049 \func{wxFileName\& operator
}{operator=
}{\param{const wxFileName\&
}{filename
}}
1051 \func{wxFileName\& operator
}{operator=
}{\param{const wxString\&
}{filename
}}
1053 Assigns the new value to this filename object.
1056 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
1058 \constfunc{bool operator
}{operator==
}{\param{const wxFileName\&
}{filename
}}
1060 \constfunc{bool operator
}{operator==
}{\param{const wxString\&
}{filename
}}
1062 Returns
{\tt true
} if the filenames are equal. The string
{\it filenames
} is
1063 interpreted as a path in the native filename format.
1066 \membersection{wxFileName::operator!=
}\label{wxfilenameoperatornotequal
}
1068 \constfunc{bool operator
}{operator!=
}{\param{const wxFileName\&
}{filename
}}
1070 \constfunc{bool operator
}{operator!=
}{\param{const wxString\&
}{filename
}}
1072 Returns
{\tt true
} if the filenames are different. The string
{\it filenames
}
1073 is interpreted as a path in the native filename format.