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{wxWindows 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{Data structures
}
28 Many wxFileName methods accept the path format argument which is by
\rtfsp
29 {\tt wxPATH
\_NATIVE} by default meaning to use the path format native for the
32 The path format affects the operation of wxFileName functions in several ways:
33 first and foremost, it defines the path separator character to use, but it also
34 affects other things such as whether the path has the drive part or not.
39 wxPATH_NATIVE =
0, // the path format for the current platform
45 wxPATH_BEOS = wxPATH_UNIX,
46 wxPATH_WIN = wxPATH_DOS,
47 wxPATH_OS2 = wxPATH_DOS
51 The kind of normalization to do with the file name: these values can be
52 or'd together to perform several operations at once in
\rtfsp
53 \helpref{Normalize
}{wxfilenamenormalize
}.
58 wxPATH_NORM_ENV_VARS =
0x0001, // replace env vars with their values
59 wxPATH_NORM_DOTS =
0x0002, // squeeze all .. and . and prepend cwd
60 wxPATH_NORM_TILDE =
0x0004, // Unix only: replace ~ and ~user
61 wxPATH_NORM_CASE =
0x0008, // if case insensitive => tolower
62 wxPATH_NORM_ABSOLUTE =
0x0010, // make the path absolute
63 wxPATH_NORM_LONG =
0x0020, // make the path the long form
64 wxPATH_NORM_ALL =
0x003f
68 \latexignore{\rtfignore{\wxheading{Members
}}}
70 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilenamedef
}
72 \func{}{wxFileName
}{\void}
76 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilenamecopy
}
78 \func{}{wxFileName
}{\param{const wxFileName\&
}{filename
}}
82 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename1
}
84 \func{}{wxFileName
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
86 from a full filename: if it terminates with a '/', a directory path
87 is contructed (the name will be empty), otherwise a file name and
88 extension are extracted from it
91 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename2
}
93 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
95 from a directory name and a file name
98 \membersection{wxFileName::wxFileName
}\label{wxfilenamewxfilename3
}
100 \func{}{wxFileName
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
102 from a directory name, file base name and extension
105 \membersection{wxFileName::AppendDir
}\label{wxfilenameappenddir
}
107 \func{void
}{AppendDir
}{\param{const wxString\&
}{dir
}}
110 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
112 \func{void
}{Assign
}{\param{const wxFileName\&
}{filepath
}}
115 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
117 \func{void
}{Assign
}{\param{const wxString\&
}{fullpath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
120 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
122 \func{void
}{Assign
}{\param{const wxString\&
}{volume
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
125 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
127 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
130 \membersection{wxFileName::Assign
}\label{wxfilenameassign
}
132 \func{void
}{Assign
}{\param{const wxString\&
}{path
},
\param{const wxString\&
}{name
},
\param{const wxString\&
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
135 \membersection{wxFileName::AssignCwd
}\label{wxfilenameassigncwd
}
137 \func{void
}{AssignCwd
}{\void}
139 various file/dir operations
140 retrieve the value of the current working directory
143 \membersection{wxFileName::AssignDir
}\label{wxfilenameassigndir
}
145 \func{void
}{AssignDir
}{\param{const wxString\&
}{dir
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
150 \membersection{wxFileName::AssignHomeDir
}\label{wxfilenameassignhomedir
}
152 \func{void
}{AssignHomeDir
}{\void}
154 get the value of user home (Unix only mainly)
157 \membersection{wxFileName::AssignTempFileName
}\label{wxfilenameassigntempfilename
}
159 \func{void
}{AssignTempFileName
}{\param{const wxString\&
}{prefix
}}
161 get a temp file name starting with thespecified prefix
164 \membersection{wxFileName::Clear
}\label{wxfilenameclear
}
166 \func{void
}{Clear
}{\void}
168 reset all components to default, uninitialized state
171 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
173 \func{bool
}{DirExists
}{\void}
175 does the directory with this name exists?
178 \membersection{wxFileName::DirExists
}\label{wxfilenamedirexists
}
180 \func{bool
}{DirExists
}{\param{const wxString\&
}{dir
}}
183 \membersection{wxFileName::DirName
}\label{wxfilenamedirname
}
185 \func{wxFileName
}{DirName
}{\param{const wxString\&
}{dir
}}
188 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
190 \func{bool
}{FileExists
}{\void}
192 does the file with this name exists?
195 \membersection{wxFileName::FileExists
}\label{wxfilenamefileexists
}
197 \func{bool
}{FileExists
}{\param{const wxString\&
}{file
}}
200 \membersection{wxFileName::FileName
}\label{wxfilenamefilename
}
202 \func{wxFileName
}{FileName
}{\param{const wxString\&
}{file
}}
204 static pseudo constructors
207 \membersection{wxFileName::GetCwd
}\label{wxfilenamegetcwd
}
209 \func{wxString
}{GetCwd
}{\void}
212 \membersection{wxFileName::GetDirCount
}\label{wxfilenamegetdircount
}
214 \constfunc{size
\_t}{GetDirCount
}{\void}
217 \membersection{wxFileName::GetDirs
}\label{wxfilenamegetdirs
}
219 \constfunc{const wxArrayString\&
}{GetDirs
}{\void}
222 \membersection{wxFileName::GetExt
}\label{wxfilenamegetext
}
224 \constfunc{wxString
}{GetExt
}{\void}
227 \membersection{wxFileName::GetFormat
}\label{wxfilenamegetformat
}
229 \func{wxPathFormat
}{GetFormat
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
232 get the canonical path format for this platform
235 \membersection{wxFileName::GetFullName
}\label{wxfilenamegetfullname
}
237 \constfunc{wxString
}{GetFullName
}{\void}
240 \membersection{wxFileName::GetFullPath
}\label{wxfilenamegetfullpath
}
242 \constfunc{wxString
}{GetFullPath
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
244 add separator Construct full path with name and ext
247 \membersection{wxFileName::GetHomeDir
}\label{wxfilenamegethomedir
}
249 \func{wxString
}{GetHomeDir
}{\void}
252 \membersection{wxFileName::GetLongPath
}\label{wxfilenamegetlongpath
}
254 \constfunc{wxString
}{GetLongPath
}{\void}
256 Return the long form of the path (returns identity on non-Windows platforms)
259 \membersection{wxFileName::GetModificationTime
}\label{wxfilenamegetmodificationtime
}
261 \constfunc{wxDateTime
}{GetModificationTime
}{\void}
263 convenience wrapper: get just the last mod time of the file
266 \membersection{wxFileName::GetName
}\label{wxfilenamegetname
}
268 \constfunc{wxString
}{GetName
}{\void}
271 \membersection{wxFileName::GetPath
}\label{wxfilenamegetpath
}
273 \constfunc{wxString
}{GetPath
}{\param{bool
}{add
\_separator = FALSE
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
275 Construct path only - possibly with the trailing separator
278 \membersection{wxFileName::GetPathSeparators
}\label{wxfilenamegetpathseparators
}
280 \func{wxString
}{GetPathSeparators
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
282 get the string of path separators for this format
285 \membersection{wxFileName::GetPathWithSep
}\label{wxfilenamegetpathwithsep
}
287 \constfunc{wxString
}{GetPathWithSep
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
289 more readable synonym
292 \membersection{wxFileName::GetShortPath
}\label{wxfilenamegetshortpath
}
294 \constfunc{wxString
}{GetShortPath
}{\void}
296 Return the short form of the path (returns identity on non-Windows platforms)
299 \membersection{wxFileName::GetTimes
}\label{wxfilenamegettimes
}
301 \constfunc{bool
}{GetTimes
}{\param{wxDateTime*
}{dtAccess
},
\param{wxDateTime*
}{dtMod
},
\param{wxDateTime*
}{dtChange
}}
303 return the last access, last modification and last change times
304 (any of the pointers may be NULL)
307 \membersection{wxFileName::GetVolume
}\label{wxfilenamegetvolume
}
309 \constfunc{wxString
}{GetVolume
}{\void}
312 \membersection{wxFileName::GetVolumeSeparator
}\label{wxfilenamegetvolumeseparator
}
314 \func{wxString
}{GetVolumeSeparator
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
316 get the string separating the volume from the path for this format
319 \membersection{wxFileName::HasExt
}\label{wxfilenamehasext
}
321 \constfunc{bool
}{HasExt
}{\void}
324 \membersection{wxFileName::HasName
}\label{wxfilenamehasname
}
326 \constfunc{bool
}{HasName
}{\void}
329 \membersection{wxFileName::HasVolume
}\label{wxfilenamehasvolume
}
331 \constfunc{bool
}{HasVolume
}{\void}
334 \membersection{wxFileName::InsertDir
}\label{wxfilenameinsertdir
}
336 \func{void
}{InsertDir
}{\param{int
}{before
},
\param{const wxString\&
}{dir
}}
339 \membersection{wxFileName::IsAbsolute
}\label{wxfilenameisabsolute
}
341 \func{bool
}{IsAbsolute
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
343 is this filename absolute?
346 \membersection{wxFileName::IsCaseSensitive
}\label{wxfilenameiscasesensitive
}
348 \func{bool
}{IsCaseSensitive
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
351 are the file names of this type cases sensitive?
354 \membersection{wxFileName::IsOk
}\label{wxfilenameisok
}
356 \constfunc{bool
}{IsOk
}{\void}
359 is the filename valid at all?
362 \membersection{wxFileName::IsPathSeparator
}\label{wxfilenameispathseparator
}
364 \func{bool
}{IsPathSeparator
}{\param{wxChar
}{ch
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
366 is the char a path separator for this format?
369 \membersection{wxFileName::IsRelative
}\label{wxfilenameisrelative
}
371 \func{bool
}{IsRelative
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
373 is this filename relative?
376 \membersection{wxFileName::IsWild
}\label{wxfilenameiswild
}
378 \func{bool
}{IsWild
}{\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
380 FIXME: what exactly does this do?
383 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
385 \func{bool
}{Mkdir
}{\param{int
}{perm =
0777},
\param{bool
}{full = FALSE
}}
387 directory creation and removal.
388 if full is TRUE, will try to make each directory in the path.
391 \membersection{wxFileName::Mkdir
}\label{wxfilenamemkdir
}
393 \func{bool
}{Mkdir
}{\param{const wxString\&
}{dir
},
\param{int
}{perm =
0777},
\param{bool
}{full = FALSE
}}
396 \membersection{wxFileName::Normalize
}\label{wxfilenamenormalize
}
398 \func{bool
}{Normalize
}{\param{wxPathNormalize
}{flags = wxPATH
\_NORM\_ALL},
\param{const wxString\&
}{cwd = wxEmptyString
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
400 operations on the path
401 normalize the path: with the default flags value, the path will be
402 made absolute, without any ".." and "." and all environment
403 variables will be expanded in it
404 this may be done using another (than current) value of cwd
407 \membersection{wxFileName::PrependDir
}\label{wxfilenameprependdir
}
409 \func{void
}{PrependDir
}{\param{const wxString\&
}{dir
}}
412 \membersection{wxFileName::RemoveDir
}\label{wxfilenameremovedir
}
414 \func{void
}{RemoveDir
}{\param{int
}{pos
}}
417 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
419 \func{bool
}{Rmdir
}{\void}
422 \membersection{wxFileName::Rmdir
}\label{wxfilenamermdir
}
424 \func{bool
}{Rmdir
}{\param{const wxString\&
}{dir
}}
427 \membersection{wxFileName::SameAs
}\label{wxfilenamesameas
}
429 \func{bool
}{SameAs
}{\param{const wxFileName\&
}{filepath
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
431 compares with the rules of this platform
434 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
436 \func{bool
}{SetCwd
}{\void}
438 change the current working directory
441 \membersection{wxFileName::SetCwd
}\label{wxfilenamesetcwd
}
443 \func{bool
}{SetCwd
}{\param{const wxString\&
}{cwd
}}
446 \membersection{wxFileName::SetExt
}\label{wxfilenamesetext
}
448 \func{void
}{SetExt
}{\param{const wxString\&
}{ext
}}
451 \membersection{wxFileName::SetFullName
}\label{wxfilenamesetfullname
}
453 \func{void
}{SetFullName
}{\param{const wxString\&
}{fullname
}}
455 full name is the file name + extension (but without the path)
458 \membersection{wxFileName::SetName
}\label{wxfilenamesetname
}
460 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
463 \membersection{wxFileName::SetTimes
}\label{wxfilenamesettimes
}
465 \func{bool
}{SetTimes
}{\param{const wxDateTime*
}{dtCreate
},
\param{const wxDateTime*
}{dtAccess
},
\param{const wxDateTime*
}{dtMod
}}
467 set the file creation and last access/mod times
468 (any of the pointers may be NULL)
471 \membersection{wxFileName::SetVolume
}\label{wxfilenamesetvolume
}
473 \func{void
}{SetVolume
}{\param{const wxString\&
}{volume
}}
476 \membersection{wxFileName::SplitPath
}\label{wxfilenamesplitpath
}
478 \func{void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{volume
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
480 \func{void
}{SplitPath
}{\param{const wxString\&
}{fullpath
},
\param{wxString*
}{path
},
\param{wxString*
}{name
},
\param{wxString*
}{ext
},
\param{wxPathFormat
}{format = wxPATH
\_NATIVE}}
482 split a fullpath into the volume, path, (base) name and extension
483 (all of the pointers can be NULL)
485 \membersection{wxFileName::Touch
}\label{wxfilenametouch
}
487 \func{bool
}{Touch
}{\void}
489 set the access and modification times to the current moment
492 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
494 \func{wxFileName\& operator
}{operator=
}{\param{const wxFileName\&
}{filename
}}
497 \membersection{wxFileName::operator=
}\label{wxfilenameoperatorassign
}
499 \func{wxFileName\& operator
}{operator=
}{\param{const wxString\&
}{filename
}}
502 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
504 \func{bool operator
}{operator==
}{\param{const wxFileName\&
}{filename
}}
506 uses the current platform settings
509 \membersection{wxFileName::operator==
}\label{wxfilenameoperatorequal
}
511 \func{bool operator
}{operator==
}{\param{const wxString\&
}{filename
}}