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 \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 whether the file name is absolute or relative also
77 depend on the file name format and the only portable way to answer this
78 question is to use
\helpref{IsAbsolute
}{wxfilenameisabsolute
} or
\rtfsp
79 \helpref{IsRelative
}{wxfilenameisrelative
} method. Note that on Windows, "X:"
80 refers to the current working directory on drive X. Therefore, a wxFileName
81 instance constructed from for example "X:dir/file.ext" treats the portion
82 beyond drive separator as being relative to that directory.
84 To ensure that the filename is absolute, you may use
\rtfsp
85 \helpref{MakeAbsolute
}{wxfilenamemakeabsolute
}. There is also an inverse
86 function
\helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
} which undoes
87 what
\helpref{Normalize(wxPATH
\_NORM\_DOTS)
}{wxfilenamenormalize
} does.
89 Other functions returning information about the file format provided by this
90 class are
\helpref{GetVolumeSeparator
}{wxfilenamegetvolumeseparator
},
\rtfsp
91 \helpref{IsPathSeparator
}{wxfilenameispathseparator
}.
94 \membersection{File name construction
}\label{filenameconstruction
}
96 You can initialize a wxFileName instance using one of the following functions:
98 \helpref{wxFileName constructors
}{wxfilenamewxfilename
}\\
99 \helpref{Assign
}{wxfilenameassign
}\\
100 \helpref{AssignCwd
}{wxfilenameassigncwd
}\\
101 \helpref{AssignDir
}{wxfilenameassigndir
}\\
102 \helpref{AssignHomeDir
}{wxfilenameassignhomedir
}\\
103 \helpref{AssignHomeTempFileName
}{wxfilenameassigntempfilename
}\\
104 \helpref{operator $=$
}{wxfilenameoperatorassign
}
107 \membersection{File tests
}\label{filetests
}
109 Before doing other tests, you should use
\helpref{IsOk
}{wxfilenameisok
} to
110 verify that the filename is well defined. If it is,
\rtfsp
111 \helpref{FileExists
}{wxfilenamefileexists
} can be used to test whether a file
112 with such name exists and
\helpref{DirExists
}{wxfilenamedirexists
} can be used
113 to test for directory existence.
115 File names should be compared using
\helpref{SameAs
}{wxfilenamesameas
} method
116 or
\helpref{operator $==$
}{wxfilenameoperatorequal
}.
118 For testing basic access modes, you can use:
120 \helpref{IsDirWritable
}{wxfilenameisdirwritable
}\\
121 \helpref{IsDirReadable
}{wxfilenameisdirreadable
}\\
122 \helpref{IsFileWritable
}{wxfilenameisfilewritable
}\\
123 \helpref{IsFileReadable
}{wxfilenameisfilereadable
}\\
124 \helpref{IsFileExecutable
}{wxfilenameisfileexecutable
}
127 \membersection{File name components
}\label{filenamecomponents
}
129 These functions allow to examine and modify the individual directories of the
132 \helpref{AppendDir
}{wxfilenameappenddir
}\\
133 \helpref{InsertDir
}{wxfilenameinsertdir
}\\
134 \helpref{GetDirCount
}{wxfilenamegetdircount
}
135 \helpref{PrependDir
}{wxfilenameprependdir
}\\
136 \helpref{RemoveDir
}{wxfilenameremovedir
}\\
137 \helpref{RemoveLastDir
}{wxfilenameremovelastdir
}
139 To change the components of the file name individually you can use the
142 \helpref{GetExt
}{wxfilenamegetext
}\\
143 \helpref{GetName
}{wxfilenamegetname
}\\
144 \helpref{GetVolume
}{wxfilenamegetvolume
}\\
145 \helpref{HasExt
}{wxfilenamehasext
}\\
146 \helpref{HasName
}{wxfilenamehasname
}\\
147 \helpref{HasVolume
}{wxfilenamehasvolume
}\\
148 \helpref{SetExt
}{wxfilenamesetext
}\\
149 \helpref{ClearExt
}{wxfilenameclearext
}\\
150 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}\\
151 \helpref{SetName
}{wxfilenamesetname
}\\
152 \helpref{SetVolume
}{wxfilenamesetvolume
}\\
155 \membersection{Operations
}\label{filenameoperations
}
157 These methods allow to work with the file creation, access and modification
158 times. Note that not all filesystems under all platforms implement these times
159 in the same way. For example, the access time under Windows has a resolution of
160 one day (so it is really the access date and not time). The access time may be
161 updated when the file is executed or not depending on the platform.
163 \helpref{GetModificationTime
}{wxfilenamegetmodificationtime
}\\
164 \helpref{GetTimes
}{wxfilenamegettimes
}\\
165 \helpref{SetTimes
}{wxfilenamesettimes
}\\
166 \helpref{Touch
}{wxfilenametouch
}
168 Other file system operations functions are:
170 \helpref{Mkdir
}{wxfilenamemkdir
}\\
171 \helpref{Rmdir
}{wxfilenamermdir
}
173 \latexignore{\rtfignore{\wxheading{Members
}}}
176 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename
}
178 \func{}{wxFileName
}{\void}
182 \func{}{wxFileName
}{\param{const wxFileName\&
}{filename
}}
186 \func{}{wxFileName
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
188 Constructor taking a full filename. If it terminates with a '/', a directory path
189 is constructed (the name will be empty), otherwise a file name and
190 extension are extracted from it.
192 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
194 Constructor from a directory name and a file name.
196 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
198 Constructor from a directory name, base file name and extension.
200 \func{}{wxFileName
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
202 Constructor from a volume name, a directory name, base file name and extension.
205 \membersection{wxFileName::AppendDir
}\label{wxfilenameappenddir
}
207 \func{void
}{AppendDir
}{\param{const wxString\&
}{dir
}}
209 Appends a directory component to the path. This component should contain a
210 single directory name level, i.e. not contain any path or volume separators nor
211 should it be empty, otherwise the function does nothing (and generates an
212 assert failure in debug build).
215 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
217 \func{void
}{Assign
}{\param{const wxFileName\&
}{filepath
}}
219 \func{void
}{Assign
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
221 \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}}
223 \func{void
}{Assign
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
225 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
227 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
229 Creates the file name from various combinations of data.
232 \membersection{wxFileName::AssignCwd
}\label{wxfilenameassigncwd
}
234 \func{static void
}{AssignCwd
}{\param{const wxString\&
}{volume = wxEmptyString
}}
236 Makes this object refer to the current working directory on the specified
237 volume (or current volume if
{\it volume
} is empty).
241 \helpref{GetCwd
}{wxfilenamegetcwd
}
244 \membersection{wxFileName::AssignDir
}\label{wxfilenameassigndir
}
246 \func{void
}{AssignDir
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
248 Sets this file name object to the given directory name. The name and extension
252 \membersection{wxFileName::AssignHomeDir
}\label{wxfilenameassignhomedir
}
254 \func{void
}{AssignHomeDir
}{\void}
256 Sets this file name object to the home directory.
259 \membersection{wxFileName::AssignTempFileName
}\label{wxfilenameassigntempfilename
}
261 \func{void
}{AssignTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
263 The function calls
\helpref{CreateTempFileName
}{wxfilenamecreatetempfilename
} to
264 create a temporary file and sets this object to the name of the file. If a
265 temporary file couldn't be created, the object is put into the
\rtfsp
266 \helpref{invalid
}{wxfilenameisok
} state.
269 \membersection{wxFileName::Clear
}\label{wxfilenameclear
}
271 \func{void
}{Clear
}{\void}
273 Reset all components to default, uninitialized state.
276 \membersection{wxFileName::ClearExt
}\label{wxfilenameclearext
}
278 \func{void
}{SetClearExt
}{\void}
280 Removes the extension from the file name resulting in a
281 file name with no trailing dot.
285 \helpref{SetExt
}{wxfilenamesetext
}
286 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
288 \membersection{wxFileName::CreateTempFileName
}\label{wxfilenamecreatetempfilename
}
290 \func{static wxString
}{CreateTempFileName
}{\param{const wxString\&
}{prefix
},
\param{wxFile *
}{fileTemp =
{\tt NULL
}}}
292 Returns a temporary file name starting with the given
{\it prefix
}. If
293 the
{\it prefix
} is an absolute path, the temporary file is created in this
294 directory, otherwise it is created in the default system directory for the
295 temporary files or in the current directory.
297 If the function succeeds, the temporary file is actually created. If
\rtfsp
298 {\it fileTemp
} is not
{\tt NULL
}, this file will be opened using the name of
299 the temporary file. When possible, this is done in an atomic way ensuring that
300 no race condition occurs between the temporary file name generation and opening
301 it which could often lead to security compromise on the multiuser systems.
302 If
{\it fileTemp
} is
{\tt NULL
}, the file is only created, but not opened.
304 Under Unix, the temporary file will have read and write permissions for the
305 owner only to minimize the security problems.
307 \wxheading{Parameters
}
309 \docparam{prefix
}{Prefix to use for the temporary file name construction
}
311 \docparam{fileTemp
}{The file to open or
{\tt NULL
} to just get the name
}
313 \wxheading{Return value
}
315 The full temporary file name or an empty string on error.
318 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
320 \constfunc{bool
}{DirExists
}{\void}
322 \func{static bool
}{DirExists
}{\param{const wxString\&
}{dir
}}
324 Returns
{\tt true
} if the directory with this name exists.
327 \membersection{wxFileName::DirName
}\label{wxfilenamedirname
}
329 \func{static wxFileName
}{DirName
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
331 Returns the object corresponding to the directory with the given name.
332 The
{\it dir
} parameter may have trailing path separator or not.
336 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
338 \constfunc{bool
}{FileExists
}{\void}
340 \func{static bool
}{FileExists
}{\param{const wxString\&
}{file
}}
342 Returns
{\tt true
} if the file with this name exists.
346 \helpref{DirExists
}{wxfilenamedirexists
}
350 \membersection{wxFileName::FileName
}\label{wxfilenamefilename
}
352 \func{static wxFileName
}{FileName
}{\param{const wxString\&
}{file
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
354 Returns the file name object corresponding to the given
{\it file
}. This
355 function exists mainly for symmetry with
\helpref{DirName
}{wxfilenamedirname
}.
359 \membersection{wxFileName::GetCwd
}\label{wxfilenamegetcwd
}
361 \func{static wxString
}{GetCwd
}{\param{const wxString\&
}{volume = ""
}}
363 Retrieves the value of the current working directory on the specified volume. If
364 the volume is empty, the program's current working directory is returned for the
367 \wxheading{Return value
}
369 The string containing the current working directory or an empty string on
374 \helpref{AssignCwd
}{wxfilenameassigncwd
}
377 \membersection{wxFileName::GetDirCount
}\label{wxfilenamegetdircount
}
379 \constfunc{size
\_t}{GetDirCount
}{\void}
381 Returns the number of directories in the file name.
384 \membersection{wxFileName::GetDirs
}\label{wxfilenamegetdirs
}
386 \constfunc{const wxArrayString\&
}{GetDirs
}{\void}
388 Returns the directories in string array form.
391 \membersection{wxFileName::GetExt
}\label{wxfilenamegetext
}
393 \constfunc{wxString
}{GetExt
}{\void}
395 Returns the file name extension.
398 \membersection{wxFileName::GetForbiddenChars
}\label{wxfilenamegetforbiddenchars
}
400 \func{static wxString
}{GetForbiddenChars
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
402 Returns the characters that can't be used in filenames and directory names for the specified format.
405 \membersection{wxFileName::GetFormat
}\label{wxfilenamegetformat
}
407 \func{static wxPathFormat
}{GetFormat
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
409 Returns the canonical path format for this platform.
412 \membersection{wxFileName::GetFullName
}\label{wxfilenamegetfullname
}
414 \constfunc{wxString
}{GetFullName
}{\void}
416 Returns the full name (including extension but excluding directories).
419 \membersection{wxFileName::GetFullPath
}\label{wxfilenamegetfullpath
}
421 \constfunc{wxString
}{GetFullPath
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
423 Returns the full path with name and extension.
426 \membersection{wxFileName::GetHomeDir
}\label{wxfilenamegethomedir
}
428 \func{static wxString
}{GetHomeDir
}{\void}
430 Returns the home directory.
433 \membersection{wxFileName::GetLongPath
}\label{wxfilenamegetlongpath
}
435 \constfunc{wxString
}{GetLongPath
}{\void}
437 Return the long form of the path (returns identity on non-Windows platforms)
440 \membersection{wxFileName::GetModificationTime
}\label{wxfilenamegetmodificationtime
}
442 \constfunc{wxDateTime
}{GetModificationTime
}{\void}
444 Returns the last time the file was last modified.
447 \membersection{wxFileName::GetName
}\label{wxfilenamegetname
}
449 \constfunc{wxString
}{GetName
}{\void}
451 Returns the name part of the filename (without extension).
455 \helpref{GetFullName
}{wxfilenamegetfullname
}
459 \membersection{wxFileName::GetPath
}\label{wxfilenamegetpath
}
461 \constfunc{wxString
}{GetPath
}{\param{int
}{flags =
{\tt wxPATH
\_GET\_VOLUME}},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
463 Returns the path part of the filename (without the name or extension). The
464 possible flags values are:
467 \begin{twocollist
}\itemsep=
0pt
468 \twocolitem{{\bf wxPATH
\_GET\_VOLUME}}{Return the path with the volume (does
469 nothing for the filename formats without volumes), otherwise the path without
470 volume part is returned.
}
471 \twocolitem{{\bf wxPATH
\_GET\_SEPARATOR}}{Return the path with the trailing
472 separator, if this flag is not given there will be no separator at the end of
477 \membersection{wxFileName::GetPathSeparator
}\label{wxfilenamegetpathseparator
}
479 \func{static wxChar
}{GetPathSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
481 Returns the usually used path separator for this format. For all formats but
482 {\tt wxPATH
\_DOS} there is only one path separator anyhow, but for DOS there
483 are two of them and the native one, i.e. the backslash is returned by this
488 \helpref{GetPathSeparators
}{wxfilenamegetpathseparators
}
491 \membersection{wxFileName::GetPathSeparators
}\label{wxfilenamegetpathseparators
}
493 \func{static wxString
}{GetPathSeparators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
495 Returns the string containing all the path separators for this format. For all
496 formats but
{\tt wxPATH
\_DOS} this string contains only one character but for
497 DOS and Windows both
{\tt '/'
} and
{\tt '
\textbackslash'
} may be used as
502 \helpref{GetPathSeparator
}{wxfilenamegetpathseparator
}
505 \membersection{wxFileName::GetPathTerminators
}\label{wxfilenamegetpathterminators
}
507 \func{static wxString
}{GetPathTerminators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
509 Returns the string of characters which may terminate the path part. This is the
510 same as
\helpref{GetPathSeparators
}{wxfilenamegetpathseparators
} except for VMS
511 path format where $
]$ is used at the end of the path part.
514 \membersection{wxFileName::GetPathWithSep
}\label{wxfilenamegetpathwithsep
}
516 \constfunc{wxString
}{GetPathWithSep
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
518 Returns the path with the trailing separator, useful for appending the name to
521 This is the same as calling
\helpref{GetPath
}{wxfilenamegetpath
}
522 \texttt{(wxPATH
\_GET\_VOLUME | wxPATH
\_GET\_SEPARATOR, format)
}.
525 \membersection{wxFileName::GetShortPath
}\label{wxfilenamegetshortpath
}
527 \constfunc{wxString
}{GetShortPath
}{\void}
529 Return the short form of the path (returns identity on non-Windows platforms).
532 \membersection{wxFileName::GetSize
}\label{wxfilenamegetsize
}
534 \constfunc{wxULongLong
}{GetSize
}{\void}
536 \func{static wxULongLong
}{GetSize
}{\param{const wxString\&
}{filename
}}
538 Returns the size of this file (first form) or the size of the given file (second form).
539 If the file does not exist or its size could not be read (because e.g. the file is locked
540 by another process) the returned value is
{\tt wxInvalidSize
}.
543 \membersection{wxFileName::GetHumanReadableSize
}\label{wxfilenamegethumanreadablesize
}
545 \constfunc{wxString
}{GetHumanReadableSize
}{\param{const wxString\&
}{failmsg = "Not available"
},
\param{int
}{precision =
1}}
547 \func{static wxString
}{GetHumanReadableSize
}{\param{const wxULongLong\&
}{bytes
},
\param{const wxString\&
}{nullsize = "Not available"
},
\param{int
}{precision =
1}}
549 Returns the size of this file (first form) or the given number of bytes (second form)
550 in a human-readable form.
552 If the size could not be retrieved the
{\tt failmsg
} string is returned (first form).
553 If
{\tt bytes
} is
{\tt wxInvalidSize
} or zero, then
{\tt nullsize
} is returned (second form).
555 In case of success, the returned string is a floating-point number with
{\tt precision
} decimal digits
556 followed by the size unit (B, kB, MB, GB, TB: respectively bytes, kilobytes, megabytes, gigabytes, terabytes).
559 \membersection{wxFileName::GetTimes
}\label{wxfilenamegettimes
}
561 \constfunc{bool
}{GetTimes
}{\param{wxDateTime*
}{dtAccess
},
\param{wxDateTime*
}{dtMod
},
\param{wxDateTime*
}{dtCreate
}}
563 Returns the last access, last modification and creation times. The last access
564 time is updated whenever the file is read or written (or executed in the case
565 of Windows), last modification time is only changed when the file is written
566 to. Finally, the creation time is indeed the time when the file was created
567 under Windows and the inode change time under Unix (as it is impossible to
568 retrieve the real file creation time there anyhow) which can also be changed
569 by many operations after the file creation.
571 Any of the pointers may be
{\tt NULL
} if the corresponding time is not
574 \wxheading{Return value
}
576 {\tt true
} on success,
{\tt false
} if we failed to retrieve the times.
579 \membersection{wxFileName::GetVolume
}\label{wxfilenamegetvolume
}
581 \constfunc{wxString
}{GetVolume
}{\void}
583 Returns the string containing the volume for this file name, empty if it
584 doesn't have one or if the file system doesn't support volumes at all (for
588 \membersection{wxFileName::GetVolumeSeparator
}\label{wxfilenamegetvolumeseparator
}
590 \func{static wxString
}{GetVolumeSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
592 Returns the string separating the volume from the path for this format.
595 \membersection{wxFileName::HasExt
}\label{wxfilenamehasext
}
597 \constfunc{bool
}{HasExt
}{\void}
599 Returns
{\tt true
} if an extension is present.
602 \membersection{wxFileName::HasName
}\label{wxfilenamehasname
}
604 \constfunc{bool
}{HasName
}{\void}
606 Returns
{\tt true
} if a name is present.
609 \membersection{wxFileName::HasVolume
}\label{wxfilenamehasvolume
}
611 \constfunc{bool
}{HasVolume
}{\void}
613 Returns
{\tt true
} if a volume specifier is present.
616 \membersection{wxFileName::InsertDir
}\label{wxfilenameinsertdir
}
618 \func{void
}{InsertDir
}{\param{size
\_t }{before
},
\param{const wxString\&
}{dir
}}
620 Inserts a directory component before the zero-based position in the directory
621 list. Please see
\helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
624 \membersection{wxFileName::IsAbsolute
}\label{wxfilenameisabsolute
}
626 \func{bool
}{IsAbsolute
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
628 Returns
{\tt true
} if this filename is absolute.
631 \membersection{wxFileName::IsCaseSensitive
}\label{wxfilenameiscasesensitive
}
633 \func{static bool
}{IsCaseSensitive
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
635 Returns
{\tt true
} if the file names of this type are case-sensitive.
638 \membersection{wxFileName::IsDirReadable
}\label{wxfilenameisdirreadable
}
640 \constfunc{bool
}{IsDirReadable
}{\void}
642 \func{static bool
}{IsDirReadable
}{\param{const wxString\&
}{dir
}}
644 Returns
{\tt true
} if the directory component of this instance (or given
\arg{dir
})
645 is an existing directory and this process has read permissions on it.
646 Read permissions on a directory mean that you can list the directory contents but it
647 doesn't imply that you have read permissions on the files contained.
650 \membersection{wxFileName::IsDirWritable
}\label{wxfilenameisdirwritable
}
652 \constfunc{bool
}{IsDirWritable
}{\void}
654 \func{static bool
}{IsDirWritable
}{\param{const wxString\&
}{dir
}}
656 Returns
{\tt true
} if the directory component of this instance (or given
\arg{dir
})
657 is an existing directory and this process has write permissions on it.
658 Write permissions on a directory mean that you can create new files in the directory.
661 \membersection{wxFileName::IsFileExecutable
}\label{wxfilenameisfileexecutable
}
663 \constfunc{bool
}{IsFileExecutable
}{\void}
665 \func{static bool
}{IsFileExecutable
}{\param{const wxString\&
}{file
}}
667 Returns
{\tt true
} if a file with this name exists and if this process has execute permissions on it.
670 \membersection{wxFileName::IsFileReadable
}\label{wxfilenameisfilereadable
}
672 \constfunc{bool
}{IsFileReadable
}{\void}
674 \func{static bool
}{IsFileReadable
}{\param{const wxString\&
}{file
}}
676 Returns
{\tt true
} if a file with this name exists and if this process has read permissions on it.
679 \membersection{wxFileName::IsFileWritable
}\label{wxfilenameisfilewritable
}
681 \constfunc{bool
}{IsFileWritable
}{\void}
683 \func{static bool
}{IsFileWritable
}{\param{const wxString\&
}{file
}}
685 Returns
{\tt true
} if a file with this name exists and if this process has write permissions on it.
688 \membersection{wxFileName::IsOk
}\label{wxfilenameisok
}
690 \constfunc{bool
}{IsOk
}{\void}
692 Returns
{\tt true
} if the filename is valid,
{\tt false
} if it is not
693 initialized yet. The assignment functions and
694 \helpref{Clear
}{wxfilenameclear
} may reset the object to the uninitialized,
695 invalid state (the former only do it on failure).
698 \membersection{wxFileName::IsPathSeparator
}\label{wxfilenameispathseparator
}
700 \func{static bool
}{IsPathSeparator
}{\param{wxChar
}{ch
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
702 Returns
{\tt true
} if the char is a path separator for this format.
705 \membersection{wxFileName::IsRelative
}\label{wxfilenameisrelative
}
707 \func{bool
}{IsRelative
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
709 Returns
{\tt true
} if this filename is not absolute.
712 \membersection{wxFileName::IsDir
}\label{wxfilenameisdir
}
714 \constfunc{bool
}{IsDir
}{\void}
716 Returns
{\tt true
} if this object represents a directory,
{\tt false
} otherwise
717 (i.e. if it is a file). Note that this method doesn't test whether the
718 directory or file really exists, you should use
719 \helpref{DirExists
}{wxfilenamedirexists
} or
720 \helpref{FileExists
}{wxfilenamefileexists
} for this.
722 \membersection{wxFileName::MacFindDefaultTypeAndCreator
}\label{wxfilenamemacfinddefaulttypeandcreator
}
724 \func{static bool
}{MacFindDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32*
}{type
},
\param{wxUint32*
}{creator
}}
726 On Mac OS, gets the common type and creator for the given extension.
728 \membersection{wxFileName::MacRegisterDefaultTypeAndCreator
}\label{wxfilenamemacregisterdefaulttypeandcreator
}
730 \func{static void
}{MacRegisterDefaultTypeAndCreator
}{\param{const wxString\&
}{ext
},
\param{wxUint32
}{type
},
\param{wxUint32
}{creator
}}
732 On Mac OS, registers application defined extensions and their default type and creator.
734 \membersection{wxFileName::MacSetDefaultTypeAndCreator
}\label{wxfilenamemacsetdefaulttypeandcreator
}
736 \func{bool
}{MacSetDefaultTypeAndCreator
}{\void}
738 On Mac OS, looks up the appropriate type and creator from the registration and then sets it.
740 \membersection{wxFileName::MakeAbsolute
}\label{wxfilenamemakeabsolute
}
742 \func{bool
}{MakeAbsolute
}{\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
744 Make the file name absolute. This is a shortcut for
745 {\tt \helpref{Normalize
}{wxfilenamenormalize
}(wxPATH
\_NORM\_DOTS | wxPATH
\_NORM\_ABSOLUTE | wxPATH
\_NORM\_TILDE, cwd, format)
}.
749 \helpref{MakeRelativeTo
}{wxfilenamemakerelativeto
},
750 \helpref{Normalize
}{wxfilenamenormalize
},
751 \helpref{IsAbsolute
}{wxfilenameisabsolute
}
754 \membersection{wxFileName::MakeRelativeTo
}\label{wxfilenamemakerelativeto
}
756 \func{bool
}{MakeRelativeTo
}{\param{const wxString\&
}{pathBase = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
758 This function tries to put this file name in a form relative to
{\it pathBase
}.
759 In other words, it returns the file name which should be used to access this
760 file if the current directory were
{\it pathBase
}.
762 \docparam{pathBase
}{the directory to use as root, current directory is used by
765 \docparam{format
}{the file name format, native by default
}
767 \wxheading{Return value
}
769 {\tt true
} if the file name has been changed,
{\tt false
} if we failed to do
770 anything with it (currently this only happens if the file name is on a volume
771 different from the volume specified by
{\it pathBase
}).
775 \helpref{Normalize
}{wxfilenamenormalize
}
778 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
780 \func{bool
}{Mkdir
}{\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
782 \func{static bool
}{Mkdir
}{\param{const wxString\&
}{dir
},
\param{int
}{perm =
0777},
\param{int
}{flags = $
0$
}}
784 \docparam{dir
}{the directory to create
}
786 \docparam{parm
}{the permissions for the newly created directory
}
788 \docparam{flags
}{if the flags contain
{\tt wxPATH
\_MKDIR\_FULL} flag,
789 try to create each directory in the path and also don't return an error
790 if the target directory already exists.
}
792 \wxheading{Return value
}
794 Returns
{\tt true
} if the directory was successfully created,
{\tt false
}
798 \membersection{wxFileName::Normalize
}\label{wxfilenamenormalize
}
800 \func{bool
}{Normalize
}{\param{int
}{flags = wxPATH
\_NORM\_ALL},
\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
802 Normalize the path. With the default flags value, the path will be
803 made absolute, without any ".." and "." and all environment
804 variables will be expanded in it.
806 \docparam{flags
}{The kind of normalization to do with the file name. It can be
807 any or-combination of the following constants:
810 \twocolitem{{\bf wxPATH
\_NORM\_ENV\_VARS}}{replace env vars with their values
}
811 \twocolitem{{\bf wxPATH
\_NORM\_DOTS}}{squeeze all .. and . and prepend cwd
}
812 \twocolitem{{\bf wxPATH
\_NORM\_TILDE}}{Unix only: replace ~ and ~user
}
813 \twocolitem{{\bf wxPATH
\_NORM\_CASE}}{if filesystem is case insensitive, transform to lower case
}
814 \twocolitem{{\bf wxPATH
\_NORM\_ABSOLUTE}}{make the path absolute
}
815 \twocolitem{{\bf wxPATH
\_NORM\_LONG}}{make the path the long form
}
816 \twocolitem{{\bf wxPATH
\_NORM\_SHORTCUT}}{resolve if it is a shortcut (Windows only)
}
817 \twocolitem{{\bf wxPATH
\_NORM\_ALL}}{all of previous flags except
\texttt{wxPATH
\_NORM\_CASE}}
821 \docparam{cwd
}{If not empty, this directory will be used instead of current
822 working directory in normalization.
}
824 \docparam{format
}{The file name format, native by default.
}
827 \membersection{wxFileName::PrependDir
}\label{wxfilenameprependdir
}
829 \func{void
}{PrependDir
}{\param{const wxString\&
}{dir
}}
831 Prepends a directory to the file path. Please see
832 \helpref{AppendDir
}{wxfilenameappenddir
} for important notes.
836 \membersection{wxFileName::RemoveDir
}\label{wxfilenameremovedir
}
838 \func{void
}{RemoveDir
}{\param{size
\_t }{pos
}}
840 Removes the specified directory component from the path.
844 \helpref{GetDirCount
}{wxfilenamegetdircount
}
847 \membersection{wxFileName::RemoveLastDir
}\label{wxfilenameremovelastdir
}
849 \func{void
}{RemoveLastDir
}{\void}
851 Removes last directory component from the path.
854 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
856 \func{bool
}{Rmdir
}{\void}
858 \func{static bool
}{Rmdir
}{\param{const wxString\&
}{dir
}}
860 Deletes the specified directory from the file system.
863 \membersection{wxFileName::SameAs
}\label{wxfilenamesameas
}
865 \constfunc{bool
}{SameAs
}{\param{const wxFileName\&
}{filepath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
867 Compares the filename using the rules of this platform.
870 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
872 \func{bool
}{SetCwd
}{\void}
874 \func{static bool
}{SetCwd
}{\param{const wxString\&
}{cwd
}}
876 Changes the current working directory.
879 \membersection{wxFileName::SetExt
}\label{wxfilenamesetext
}
881 \func{void
}{SetExt
}{\param{const wxString\&
}{ext
}}
883 Sets the extension of the file name. Setting an empty string
884 as the extension will remove the extension resulting in a file
885 name without a trailing dot, unlike a call to
886 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}.
890 \helpref{SetEmptyExt
}{wxfilenamesetemptyext
}
891 \helpref{ClearExt
}{wxfilenameclearext
}
893 \membersection{wxFileName::SetEmptyExt
}\label{wxfilenamesetemptyext
}
895 \func{void
}{SetEmptyExt
}{\void}
897 Sets the extension of the file name to be an empty extension.
898 This is different from having no extension at all as the file
899 name will have a trailing dot after a call to this method.
903 \helpref{SetExt
}{wxfilenamesetext
}
904 \helpref{ClearExt
}{wxfilenameclearext
}
906 \membersection{wxFileName::SetFullName
}\label{wxfilenamesetfullname
}
908 \func{void
}{SetFullName
}{\param{const wxString\&
}{fullname
}}
910 The full name is the file name and extension (but without the path).
913 \membersection{wxFileName::SetName
}\label{wxfilenamesetname
}
915 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
917 Sets the name part (without extension).
921 \helpref{SetFullName
}{wxfilenamesetfullname
}
924 \membersection{wxFileName::SetTimes
}\label{wxfilenamesettimes
}
926 \func{bool
}{SetTimes
}{\param{const wxDateTime*
}{dtAccess
},
\param{const wxDateTime*
}{dtMod
},
\param{const wxDateTime*
}{dtCreate
}}
928 Sets the file creation and last access/modification times (any of the pointers may be NULL).
931 \membersection{wxFileName::SetVolume
}\label{wxfilenamesetvolume
}
933 \func{void
}{SetVolume
}{\param{const wxString\&
}{volume
}}
935 Sets the volume specifier.
938 \membersection{wxFileName::SplitPath
}\label{wxfilenamesplitpath
}
940 \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}}
942 \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}}
944 \func{static void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
946 This function splits a full file name into components: the volume (with the
947 first version) path (including the volume in the second version), the base name
948 and the extension. Any of the output parameters (
{\it volume
},
{\it path
},
949 {\it name
} or
{\it ext
}) may be
{\tt NULL
} if you are not interested in the
950 value of a particular component. Also,
{\it fullpath
} may be empty on entry.
952 On return,
{\it path
} contains the file path (without the trailing separator),
953 {\it name
} contains the file name and
{\it ext
} contains the file extension
954 without leading dot. All three of them may be empty if the corresponding
955 component is. The old contents of the strings pointed to by these parameters
956 will be overwritten in any case (if the pointers are not
{\tt NULL
}).
958 Note that for a filename ``foo.'' the extension is present, as indicated by the
959 trailing dot, but empty. If you need to cope with such cases, you should use
960 \arg{hasExt
} instead of relying on testing whether
\arg{ext
} is empty or not.
963 \membersection{wxFileName::SplitVolume
}\label{wxfilenamesplitvolume
}
965 \func{static void
}{SplitVolume
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{volume
},
\param{wxString*
}{path
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
967 Splits the given
\arg{fullpath
} into the volume part (which may be empty) and
968 the pure path part, not containing any volume.
972 \helpref{SplitPath
}{wxfilenamesplitpath
}
975 \membersection{wxFileName::Touch
}\label{wxfilenametouch
}
977 \func{bool
}{Touch
}{\void}
979 Sets the access and modification times to the current moment.
982 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
984 \func{wxFileName\& operator
}{operator=
}{\param{const wxFileName\&
}{filename
}}
986 \func{wxFileName\& operator
}{operator=
}{\param{const wxString\&
}{filename
}}
988 Assigns the new value to this filename object.
991 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
993 \constfunc{bool operator
}{operator==
}{\param{const wxFileName\&
}{filename
}}
995 \constfunc{bool operator
}{operator==
}{\param{const wxString\&
}{filename
}}
997 Returns
{\tt true
} if the filenames are equal. The string
{\it filenames
} is
998 interpreted as a path in the native filename format.
1001 \membersection{wxFileName::operator!=
}\label{wxfilenameoperatornotequal
}
1003 \constfunc{bool operator
}{operator!=
}{\param{const wxFileName\&
}{filename
}}
1005 \constfunc{bool operator
}{operator!=
}{\param{const wxString\&
}{filename
}}
1007 Returns
{\tt true
} if the filenames are different. The string
{\it filenames
}
1008 is interpreted as a path in the native filename format.