]>
Commit | Line | Data |
---|---|---|
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 | %% Name: filename.tex | |
3 | %% Purpose: wxFileName documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: 30.11.01 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) 2001 Vadim Zeitlin | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
12 | \section{\class{wxFileName}}\label{wxfilename} | |
13 | ||
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. | |
21 | ||
22 | \wxheading{Derived from} | |
23 | ||
24 | No base class | |
25 | ||
26 | \wxheading{Include files} | |
27 | ||
28 | <wx/filename.h> | |
29 | ||
30 | \wxheading{Data structures} | |
31 | ||
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 | |
34 | current platform. | |
35 | ||
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. | |
39 | ||
40 | \begin{verbatim} | |
41 | enum wxPathFormat | |
42 | { | |
43 | wxPATH_NATIVE = 0, // the path format for the current platform | |
44 | wxPATH_UNIX, | |
45 | wxPATH_BEOS = wxPATH_UNIX, | |
46 | wxPATH_MAC, | |
47 | wxPATH_DOS, | |
48 | wxPATH_WIN = wxPATH_DOS, | |
49 | wxPATH_OS2 = wxPATH_DOS, | |
50 | wxPATH_VMS, | |
51 | ||
52 | wxPATH_MAX // Not a valid value for specifying path format | |
53 | } | |
54 | \end{verbatim} | |
55 | ||
56 | \latexignore{\rtfignore{\wxheading{Function groups}}} | |
57 | ||
58 | ||
59 | \membersection{File name format}\label{filenameformat} | |
60 | ||
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. | |
72 | ||
73 | File names can be case-sensitive or not, the function\rtfsp | |
74 | \helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this. | |
75 | ||
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. | |
83 | ||
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. | |
88 | ||
89 | Other functions returning information about the file format provided by this | |
90 | class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp | |
91 | \helpref{IsPathSeparator}{wxfilenameispathseparator}. | |
92 | ||
93 | ||
94 | \membersection{File name construction}\label{filenameconstruction} | |
95 | ||
96 | TODO. | |
97 | ||
98 | ||
99 | \membersection{File tests}\label{filetests} | |
100 | ||
101 | Before doing other tests, you should use \helpref{IsOk}{wxfilenameisok} to | |
102 | verify that the filename is well defined. If it is,\rtfsp | |
103 | \helpref{FileExists}{wxfilenamefileexists} can be used to test whether a file | |
104 | with such name exists and \helpref{DirExists}{wxfilenamedirexists} can be used | |
105 | to test for directory existence. | |
106 | ||
107 | File names should be compared using \helpref{SameAs}{wxfilenamesameas} method | |
108 | or \helpref{$==$}{wxfilenameoperatorequal}. | |
109 | ||
110 | ||
111 | \membersection{File name components}\label{filenamecomponents} | |
112 | ||
113 | These functions allow to examine and modify the individual directories of the | |
114 | path: | |
115 | ||
116 | \helpref{AppendDir}{wxfilenameappenddir}\\ | |
117 | \helpref{InsertDir}{wxfilenameinsertdir}\\ | |
118 | \helpref{GetDirCount}{wxfilenamegetdircount} | |
119 | \helpref{PrependDir}{wxfilenameprependdir}\\ | |
120 | \helpref{RemoveDir}{wxfilenameremovedir}\\ | |
121 | \helpref{RemoveLastDir}{wxfilenameremovelastdir} | |
122 | ||
123 | To change the components of the file name individually you can use the | |
124 | following functions: | |
125 | ||
126 | \helpref{GetExt}{wxfilenamegetext}\\ | |
127 | \helpref{GetName}{wxfilenamegetname}\\ | |
128 | \helpref{GetVolume}{wxfilenamegetvolume}\\ | |
129 | \helpref{HasExt}{wxfilenamehasext}\\ | |
130 | \helpref{HasName}{wxfilenamehasname}\\ | |
131 | \helpref{HasVolume}{wxfilenamehasvolume}\\ | |
132 | \helpref{SetExt}{wxfilenamesetext}\\ | |
133 | \helpref{ClearExt}{wxfilenameclearext}\\ | |
134 | \helpref{SetEmptyExt}{wxfilenamesetemptyext}\\ | |
135 | \helpref{SetName}{wxfilenamesetname}\\ | |
136 | \helpref{SetVolume}{wxfilenamesetvolume}\\ | |
137 | ||
138 | ||
139 | \membersection{Operations}\label{filenameoperations} | |
140 | ||
141 | These methods allow to work with the file creation, access and modification | |
142 | times. Note that not all filesystems under all platforms implement these times | |
143 | in the same way. For example, the access time under Windows has a resolution of | |
144 | one day (so it is really the access date and not time). The access time may be | |
145 | updated when the file is executed or not depending on the platform. | |
146 | ||
147 | \helpref{GetModificationTime}{wxfilenamegetmodificationtime}\\ | |
148 | \helpref{GetTimes}{wxfilenamegettimes}\\ | |
149 | \helpref{SetTimes}{wxfilenamesettimes}\\ | |
150 | \helpref{Touch}{wxfilenametouch} | |
151 | ||
152 | Other file system operations functions are: | |
153 | ||
154 | \helpref{Mkdir}{wxfilenamemkdir}\\ | |
155 | \helpref{Rmdir}{wxfilenamermdir} | |
156 | ||
157 | \latexignore{\rtfignore{\wxheading{Members}}} | |
158 | ||
159 | ||
160 | \membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename} | |
161 | ||
162 | \func{}{wxFileName}{\void} | |
163 | ||
164 | Default constructor. | |
165 | ||
166 | \func{}{wxFileName}{\param{const wxFileName\& }{filename}} | |
167 | ||
168 | Copy constructor. | |
169 | ||
170 | \func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
171 | ||
172 | Constructor taking a full filename. If it terminates with a '/', a directory path | |
173 | is constructed (the name will be empty), otherwise a file name and | |
174 | extension are extracted from it. | |
175 | ||
176 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
177 | ||
178 | Constructor from a directory name and a file name. | |
179 | ||
180 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
181 | ||
182 | Constructor from a directory name, base file name and extension. | |
183 | ||
184 | \func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
185 | ||
186 | Constructor from a volume name, a directory name, base file name and extension. | |
187 | ||
188 | ||
189 | \membersection{wxFileName::AppendDir}\label{wxfilenameappenddir} | |
190 | ||
191 | \func{void}{AppendDir}{\param{const wxString\& }{dir}} | |
192 | ||
193 | Appends a directory component to the path. This component should contain a | |
194 | single directory name level, i.e. not contain any path or volume separators nor | |
195 | should it be empty, otherwise the function does nothing (and generates an | |
196 | assert failure in debug build). | |
197 | ||
198 | ||
199 | \membersection{wxFileName::Assign}\label{wxfilenameassign} | |
200 | ||
201 | \func{void}{Assign}{\param{const wxFileName\& }{filepath}} | |
202 | ||
203 | \func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
204 | ||
205 | \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}} | |
206 | ||
207 | \func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
208 | ||
209 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
210 | ||
211 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
212 | ||
213 | Creates the file name from various combinations of data. | |
214 | ||
215 | ||
216 | \membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd} | |
217 | ||
218 | \func{static void}{AssignCwd}{\param{const wxString\& }{volume = wxEmptyString}} | |
219 | ||
220 | Makes this object refer to the current working directory on the specified | |
221 | volume (or current volume if {\it volume} is empty). | |
222 | ||
223 | \wxheading{See also} | |
224 | ||
225 | \helpref{GetCwd}{wxfilenamegetcwd} | |
226 | ||
227 | ||
228 | \membersection{wxFileName::AssignDir}\label{wxfilenameassigndir} | |
229 | ||
230 | \func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
231 | ||
232 | Sets this file name object to the given directory name. The name and extension | |
233 | will be empty. | |
234 | ||
235 | ||
236 | \membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir} | |
237 | ||
238 | \func{void}{AssignHomeDir}{\void} | |
239 | ||
240 | Sets this file name object to the home directory. | |
241 | ||
242 | ||
243 | \membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename} | |
244 | ||
245 | \func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} | |
246 | ||
247 | The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to | |
248 | create a temporary file and sets this object to the name of the file. If a | |
249 | temporary file couldn't be created, the object is put into the\rtfsp | |
250 | \helpref{invalid}{wxfilenameisok} state. | |
251 | ||
252 | ||
253 | \membersection{wxFileName::Clear}\label{wxfilenameclear} | |
254 | ||
255 | \func{void}{Clear}{\void} | |
256 | ||
257 | Reset all components to default, uninitialized state. | |
258 | ||
259 | ||
260 | \membersection{wxFileName::ClearExt}\label{wxfilenameclearext} | |
261 | ||
262 | \func{void}{SetClearExt}{\void} | |
263 | ||
264 | Removes the extension from the file name resulting in a | |
265 | file name with no trailing dot. | |
266 | ||
267 | \wxheading{See also} | |
268 | ||
269 | \helpref{SetExt}{wxfilenamesetext} | |
270 | \helpref{SetEmptyExt}{wxfilenamesetemptyext} | |
271 | ||
272 | \membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename} | |
273 | ||
274 | \func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} | |
275 | ||
276 | Returns a temporary file name starting with the given {\it prefix}. If | |
277 | the {\it prefix} is an absolute path, the temporary file is created in this | |
278 | directory, otherwise it is created in the default system directory for the | |
279 | temporary files or in the current directory. | |
280 | ||
281 | If the function succeeds, the temporary file is actually created. If\rtfsp | |
282 | {\it fileTemp} is not {\tt NULL}, this file will be opened using the name of | |
283 | the temporary file. When possible, this is done in an atomic way ensuring that | |
284 | no race condition occurs between the temporary file name generation and opening | |
285 | it which could often lead to security compromise on the multiuser systems. | |
286 | If {\it fileTemp} is {\tt NULL}, the file is only created, but not opened. | |
287 | ||
288 | Under Unix, the temporary file will have read and write permissions for the | |
289 | owner only to minimize the security problems. | |
290 | ||
291 | \wxheading{Parameters} | |
292 | ||
293 | \docparam{prefix}{Prefix to use for the temporary file name construction} | |
294 | ||
295 | \docparam{fileTemp}{The file to open or {\tt NULL} to just get the name} | |
296 | ||
297 | \wxheading{Return value} | |
298 | ||
299 | The full temporary file name or an empty string on error. | |
300 | ||
301 | ||
302 | \membersection{wxFileName::DirExists}\label{wxfilenamedirexists} | |
303 | ||
304 | \constfunc{bool}{DirExists}{\void} | |
305 | ||
306 | \func{static bool}{DirExists}{\param{const wxString\& }{dir}} | |
307 | ||
308 | Returns {\tt true} if the directory with this name exists. | |
309 | ||
310 | ||
311 | \membersection{wxFileName::DirName}\label{wxfilenamedirname} | |
312 | ||
313 | \func{static wxFileName}{DirName}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
314 | ||
315 | Returns the object corresponding to the directory with the given name. | |
316 | The {\it dir} parameter may have trailing path separator or not. | |
317 | ||
318 | ||
319 | ||
320 | \membersection{wxFileName::FileExists}\label{wxfilenamefileexists} | |
321 | ||
322 | \constfunc{bool}{FileExists}{\void} | |
323 | ||
324 | \func{static bool}{FileExists}{\param{const wxString\& }{file}} | |
325 | ||
326 | Returns {\tt true} if the file with this name exists. | |
327 | ||
328 | \wxheading{See also} | |
329 | ||
330 | \helpref{DirExists}{wxfilenamedirexists} | |
331 | ||
332 | ||
333 | ||
334 | \membersection{wxFileName::FileName}\label{wxfilenamefilename} | |
335 | ||
336 | \func{static wxFileName}{FileName}{\param{const wxString\& }{file}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
337 | ||
338 | Returns the file name object corresponding to the given {\it file}. This | |
339 | function exists mainly for symmetry with \helpref{DirName}{wxfilenamedirname}. | |
340 | ||
341 | ||
342 | ||
343 | \membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd} | |
344 | ||
345 | \func{static wxString}{GetCwd}{\param{const wxString\& }{volume = ""}} | |
346 | ||
347 | Retrieves the value of the current working directory on the specified volume. If | |
348 | the volume is empty, the program's current working directory is returned for the | |
349 | current volume. | |
350 | ||
351 | \wxheading{Return value} | |
352 | ||
353 | The string containing the current working directory or an empty string on | |
354 | error. | |
355 | ||
356 | \wxheading{See also} | |
357 | ||
358 | \helpref{AssignCwd}{wxfilenameassigncwd} | |
359 | ||
360 | ||
361 | \membersection{wxFileName::GetDirCount}\label{wxfilenamegetdircount} | |
362 | ||
363 | \constfunc{size\_t}{GetDirCount}{\void} | |
364 | ||
365 | Returns the number of directories in the file name. | |
366 | ||
367 | ||
368 | \membersection{wxFileName::GetDirs}\label{wxfilenamegetdirs} | |
369 | ||
370 | \constfunc{const wxArrayString\&}{GetDirs}{\void} | |
371 | ||
372 | Returns the directories in string array form. | |
373 | ||
374 | ||
375 | \membersection{wxFileName::GetExt}\label{wxfilenamegetext} | |
376 | ||
377 | \constfunc{wxString}{GetExt}{\void} | |
378 | ||
379 | Returns the file name extension. | |
380 | ||
381 | ||
382 | \membersection{wxFileName::GetForbiddenChars}\label{wxfilenamegetforbiddenchars} | |
383 | ||
384 | \func{static wxString}{GetForbiddenChars}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
385 | ||
386 | Returns the characters that can't be used in filenames and directory names for the specified format. | |
387 | ||
388 | ||
389 | \membersection{wxFileName::GetFormat}\label{wxfilenamegetformat} | |
390 | ||
391 | \func{static wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
392 | ||
393 | Returns the canonical path format for this platform. | |
394 | ||
395 | ||
396 | \membersection{wxFileName::GetFullName}\label{wxfilenamegetfullname} | |
397 | ||
398 | \constfunc{wxString}{GetFullName}{\void} | |
399 | ||
400 | Returns the full name (including extension but excluding directories). | |
401 | ||
402 | ||
403 | \membersection{wxFileName::GetFullPath}\label{wxfilenamegetfullpath} | |
404 | ||
405 | \constfunc{wxString}{GetFullPath}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
406 | ||
407 | Returns the full path with name and extension. | |
408 | ||
409 | ||
410 | \membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir} | |
411 | ||
412 | \func{static wxString}{GetHomeDir}{\void} | |
413 | ||
414 | Returns the home directory. | |
415 | ||
416 | ||
417 | \membersection{wxFileName::GetLongPath}\label{wxfilenamegetlongpath} | |
418 | ||
419 | \constfunc{wxString}{GetLongPath}{\void} | |
420 | ||
421 | Return the long form of the path (returns identity on non-Windows platforms) | |
422 | ||
423 | ||
424 | \membersection{wxFileName::GetModificationTime}\label{wxfilenamegetmodificationtime} | |
425 | ||
426 | \constfunc{wxDateTime}{GetModificationTime}{\void} | |
427 | ||
428 | Returns the last time the file was last modified. | |
429 | ||
430 | ||
431 | \membersection{wxFileName::GetName}\label{wxfilenamegetname} | |
432 | ||
433 | \constfunc{wxString}{GetName}{\void} | |
434 | ||
435 | Returns the name part of the filename (without extension). | |
436 | ||
437 | \wxheading{See also} | |
438 | ||
439 | \helpref{GetFullName}{wxfilenamegetfullname} | |
440 | ||
441 | ||
442 | ||
443 | \membersection{wxFileName::GetPath}\label{wxfilenamegetpath} | |
444 | ||
445 | \constfunc{wxString}{GetPath}{\param{int }{flags = {\tt wxPATH\_GET\_VOLUME}}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
446 | ||
447 | Returns the path part of the filename (without the name or extension). The | |
448 | possible flags values are: | |
449 | ||
450 | \twocolwidtha{5cm} | |
451 | \begin{twocollist}\itemsep=0pt | |
452 | \twocolitem{{\bf wxPATH\_GET\_VOLUME}}{Return the path with the volume (does | |
453 | nothing for the filename formats without volumes), otherwise the path without | |
454 | volume part is returned.} | |
455 | \twocolitem{{\bf wxPATH\_GET\_SEPARATOR}}{Return the path with the trailing | |
456 | separator, if this flag is not given there will be no separator at the end of | |
457 | the path.} | |
458 | \end{twocollist} | |
459 | ||
460 | ||
461 | \membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator} | |
462 | ||
463 | \func{static wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
464 | ||
465 | Returns the usually used path separator for this format. For all formats but | |
466 | {\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there | |
467 | are two of them and the native one, i.e. the backslash is returned by this | |
468 | method. | |
469 | ||
470 | \wxheading{See also} | |
471 | ||
472 | \helpref{GetPathSeparators}{wxfilenamegetpathseparators} | |
473 | ||
474 | ||
475 | \membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators} | |
476 | ||
477 | \func{static wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
478 | ||
479 | Returns the string containing all the path separators for this format. For all | |
480 | formats but {\tt wxPATH\_DOS} this string contains only one character but for | |
481 | DOS and Windows both {\tt '/'} and {\tt '\textbackslash'} may be used as | |
482 | separators. | |
483 | ||
484 | \wxheading{See also} | |
485 | ||
486 | \helpref{GetPathSeparator}{wxfilenamegetpathseparator} | |
487 | ||
488 | ||
489 | \membersection{wxFileName::GetPathTerminators}\label{wxfilenamegetpathterminators} | |
490 | ||
491 | \func{static wxString}{GetPathTerminators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
492 | ||
493 | Returns the string of characters which may terminate the path part. This is the | |
494 | same as \helpref{GetPathSeparators}{wxfilenamegetpathseparators} except for VMS | |
495 | path format where $]$ is used at the end of the path part. | |
496 | ||
497 | ||
498 | \membersection{wxFileName::GetPathWithSep}\label{wxfilenamegetpathwithsep} | |
499 | ||
500 | \constfunc{wxString}{GetPathWithSep}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
501 | ||
502 | Returns the path with the trailing separator, useful for appending the name to | |
503 | the given path. | |
504 | ||
505 | This is the same as calling \helpref{GetPath}{wxfilenamegetpath} | |
506 | \texttt{(wxPATH\_GET\_VOLUME | wxPATH\_GET\_SEPARATOR, format)}. | |
507 | ||
508 | ||
509 | \membersection{wxFileName::GetShortPath}\label{wxfilenamegetshortpath} | |
510 | ||
511 | \constfunc{wxString}{GetShortPath}{\void} | |
512 | ||
513 | Return the short form of the path (returns identity on non-Windows platforms). | |
514 | ||
515 | ||
516 | \membersection{wxFileName::GetTimes}\label{wxfilenamegettimes} | |
517 | ||
518 | \constfunc{bool}{GetTimes}{\param{wxDateTime* }{dtAccess}, \param{wxDateTime* }{dtMod}, \param{wxDateTime* }{dtCreate}} | |
519 | ||
520 | Returns the last access, last modification and creation times. The last access | |
521 | time is updated whenever the file is read or written (or executed in the case | |
522 | of Windows), last modification time is only changed when the file is written | |
523 | to. Finally, the creation time is indeed the time when the file was created | |
524 | under Windows and the inode change time under Unix (as it is impossible to | |
525 | retrieve the real file creation time there anyhow) which can also be changed | |
526 | by many operations after the file creation. | |
527 | ||
528 | Any of the pointers may be {\tt NULL} if the corresponding time is not | |
529 | needed. | |
530 | ||
531 | \wxheading{Return value} | |
532 | ||
533 | {\tt true} on success, {\tt false} if we failed to retrieve the times. | |
534 | ||
535 | ||
536 | \membersection{wxFileName::GetVolume}\label{wxfilenamegetvolume} | |
537 | ||
538 | \constfunc{wxString}{GetVolume}{\void} | |
539 | ||
540 | Returns the string containing the volume for this file name, empty if it | |
541 | doesn't have one or if the file system doesn't support volumes at all (for | |
542 | example, Unix). | |
543 | ||
544 | ||
545 | \membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator} | |
546 | ||
547 | \func{static wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
548 | ||
549 | Returns the string separating the volume from the path for this format. | |
550 | ||
551 | ||
552 | \membersection{wxFileName::HasExt}\label{wxfilenamehasext} | |
553 | ||
554 | \constfunc{bool}{HasExt}{\void} | |
555 | ||
556 | Returns {\tt true} if an extension is present. | |
557 | ||
558 | ||
559 | \membersection{wxFileName::HasName}\label{wxfilenamehasname} | |
560 | ||
561 | \constfunc{bool}{HasName}{\void} | |
562 | ||
563 | Returns {\tt true} if a name is present. | |
564 | ||
565 | ||
566 | \membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume} | |
567 | ||
568 | \constfunc{bool}{HasVolume}{\void} | |
569 | ||
570 | Returns {\tt true} if a volume specifier is present. | |
571 | ||
572 | ||
573 | \membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir} | |
574 | ||
575 | \func{void}{InsertDir}{\param{size\_t }{before}, \param{const wxString\& }{dir}} | |
576 | ||
577 | Inserts a directory component before the zero-based position in the directory | |
578 | list. Please see \helpref{AppendDir}{wxfilenameappenddir} for important notes. | |
579 | ||
580 | ||
581 | \membersection{wxFileName::IsAbsolute}\label{wxfilenameisabsolute} | |
582 | ||
583 | \func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
584 | ||
585 | Returns {\tt true} if this filename is absolute. | |
586 | ||
587 | ||
588 | \membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive} | |
589 | ||
590 | \func{static bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
591 | ||
592 | Returns {\tt true} if the file names of this type are case-sensitive. | |
593 | ||
594 | ||
595 | \membersection{wxFileName::IsOk}\label{wxfilenameisok} | |
596 | ||
597 | \constfunc{bool}{IsOk}{\void} | |
598 | ||
599 | Returns {\tt true} if the filename is valid, {\tt false} if it is not | |
600 | initialized yet. The assignment functions and | |
601 | \helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized, | |
602 | invalid state (the former only do it on failure). | |
603 | ||
604 | ||
605 | \membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator} | |
606 | ||
607 | \func{static bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
608 | ||
609 | Returns {\tt true} if the char is a path separator for this format. | |
610 | ||
611 | ||
612 | \membersection{wxFileName::IsRelative}\label{wxfilenameisrelative} | |
613 | ||
614 | \func{bool}{IsRelative}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
615 | ||
616 | Returns {\tt true} if this filename is not absolute. | |
617 | ||
618 | ||
619 | \membersection{wxFileName::IsDir}\label{wxfilenameisdir} | |
620 | ||
621 | \constfunc{bool}{IsDir}{\void} | |
622 | ||
623 | Returns {\tt true} if this object represents a directory, {\tt false} otherwise | |
624 | (i.e. if it is a file). Note that this method doesn't test whether the | |
625 | directory or file really exists, you should use | |
626 | \helpref{DirExists}{wxfilenamedirexists} or | |
627 | \helpref{FileExists}{wxfilenamefileexists} for this. | |
628 | ||
629 | \membersection{wxFileName::MacFindDefaultTypeAndCreator}\label{wxfilenamemacfinddefaulttypeandcreator} | |
630 | ||
631 | \func{static bool}{MacFindDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32* }{type}, \param{wxUint32* }{creator}} | |
632 | ||
633 | On Mac OS, gets the common type and creator for the given extension. | |
634 | ||
635 | \membersection{wxFileName::MacRegisterDefaultTypeAndCreator}\label{wxfilenamemacregisterdefaulttypeandcreator} | |
636 | ||
637 | \func{static void}{MacRegisterDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32 }{type}, \param{wxUint32 }{creator}} | |
638 | ||
639 | On Mac OS, registers application defined extensions and their default type and creator. | |
640 | ||
641 | \membersection{wxFileName::MacSetDefaultTypeAndCreator}\label{wxfilenamemacsetdefaulttypeandcreator} | |
642 | ||
643 | \func{bool}{MacSetDefaultTypeAndCreator}{\void} | |
644 | ||
645 | On Mac OS, looks up the appropriate type and creator from the registration and then sets it. | |
646 | ||
647 | \membersection{wxFileName::MakeAbsolute}\label{wxfilenamemakeabsolute} | |
648 | ||
649 | \func{bool}{MakeAbsolute}{\param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
650 | ||
651 | Make the file name absolute. This is a shortcut for | |
652 | {\tt \helpref{Normalize}{wxfilenamenormalize}(wxPATH\_NORM\_DOTS | wxPATH\_NORM\_ABSOLUTE | wxPATH\_NORM\_TILDE, cwd, format)}. | |
653 | ||
654 | \wxheading{See also} | |
655 | ||
656 | \helpref{MakeRelativeTo}{wxfilenamemakerelativeto}, | |
657 | \helpref{Normalize}{wxfilenamenormalize}, | |
658 | \helpref{IsAbsolute}{wxfilenameisabsolute} | |
659 | ||
660 | ||
661 | \membersection{wxFileName::MakeRelativeTo}\label{wxfilenamemakerelativeto} | |
662 | ||
663 | \func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
664 | ||
665 | This function tries to put this file name in a form relative to {\it pathBase}. | |
666 | In other words, it returns the file name which should be used to access this | |
667 | file if the current directory were {\it pathBase}. | |
668 | ||
669 | \docparam{pathBase}{the directory to use as root, current directory is used by | |
670 | default} | |
671 | ||
672 | \docparam{format}{the file name format, native by default} | |
673 | ||
674 | \wxheading{Return value} | |
675 | ||
676 | {\tt true} if the file name has been changed, {\tt false} if we failed to do | |
677 | anything with it (currently this only happens if the file name is on a volume | |
678 | different from the volume specified by {\it pathBase}). | |
679 | ||
680 | \wxheading{See also} | |
681 | ||
682 | \helpref{Normalize}{wxfilenamenormalize} | |
683 | ||
684 | ||
685 | \membersection{wxFileName::Mkdir}\label{wxfilenamemkdir} | |
686 | ||
687 | \func{bool}{Mkdir}{\param{int }{perm = 0777}, \param{int }{flags = $0$}} | |
688 | ||
689 | \func{static bool}{Mkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}, \param{int }{flags = $0$}} | |
690 | ||
691 | \docparam{dir}{the directory to create} | |
692 | ||
693 | \docparam{parm}{the permissions for the newly created directory} | |
694 | ||
695 | \docparam{flags}{if the flags contain {\tt wxPATH\_MKDIR\_FULL} flag, | |
696 | try to create each directory in the path and also don't return an error | |
697 | if the target directory already exists.} | |
698 | ||
699 | \wxheading{Return value} | |
700 | ||
701 | Returns {\tt true} if the directory was successfully created, {\tt false} | |
702 | otherwise. | |
703 | ||
704 | ||
705 | \membersection{wxFileName::Normalize}\label{wxfilenamenormalize} | |
706 | ||
707 | \func{bool}{Normalize}{\param{int }{flags = wxPATH\_NORM\_ALL}, \param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
708 | ||
709 | Normalize the path. With the default flags value, the path will be | |
710 | made absolute, without any ".." and "." and all environment | |
711 | variables will be expanded in it. | |
712 | ||
713 | \docparam{flags}{The kind of normalization to do with the file name. It can be | |
714 | any or-combination of the following constants: | |
715 | ||
716 | \begin{twocollist} | |
717 | \twocolitem{{\bf wxPATH\_NORM\_ENV\_VARS}}{replace env vars with their values} | |
718 | \twocolitem{{\bf wxPATH\_NORM\_DOTS}}{squeeze all .. and . and prepend cwd} | |
719 | \twocolitem{{\bf wxPATH\_NORM\_TILDE}}{Unix only: replace ~ and ~user} | |
720 | \twocolitem{{\bf wxPATH\_NORM\_CASE}}{if filesystem is case insensitive, transform to lower case} | |
721 | \twocolitem{{\bf wxPATH\_NORM\_ABSOLUTE}}{make the path absolute} | |
722 | \twocolitem{{\bf wxPATH\_NORM\_LONG}}{make the path the long form} | |
723 | \twocolitem{{\bf wxPATH\_NORM\_SHORTCUT}}{resolve if it is a shortcut (Windows only)} | |
724 | \twocolitem{{\bf wxPATH\_NORM\_ALL}}{all of previous flags except \texttt{wxPATH\_NORM\_CASE}} | |
725 | \end{twocollist} | |
726 | }% | |
727 | ||
728 | \docparam{cwd}{If not empty, this directory will be used instead of current | |
729 | working directory in normalization.} | |
730 | ||
731 | \docparam{format}{The file name format, native by default.} | |
732 | ||
733 | ||
734 | \membersection{wxFileName::PrependDir}\label{wxfilenameprependdir} | |
735 | ||
736 | \func{void}{PrependDir}{\param{const wxString\& }{dir}} | |
737 | ||
738 | Prepends a directory to the file path. Please see | |
739 | \helpref{AppendDir}{wxfilenameappenddir} for important notes. | |
740 | ||
741 | ||
742 | ||
743 | \membersection{wxFileName::RemoveDir}\label{wxfilenameremovedir} | |
744 | ||
745 | \func{void}{RemoveDir}{\param{size\_t }{pos}} | |
746 | ||
747 | Removes the specified directory component from the path. | |
748 | ||
749 | \wxheading{See also} | |
750 | ||
751 | \helpref{GetDirCount}{wxfilenamegetdircount} | |
752 | ||
753 | ||
754 | \membersection{wxFileName::RemoveLastDir}\label{wxfilenameremovelastdir} | |
755 | ||
756 | \func{void}{RemoveLastDir}{\void} | |
757 | ||
758 | Removes last directory component from the path. | |
759 | ||
760 | ||
761 | \membersection{wxFileName::Rmdir}\label{wxfilenamermdir} | |
762 | ||
763 | \func{bool}{Rmdir}{\void} | |
764 | ||
765 | \func{static bool}{Rmdir}{\param{const wxString\& }{dir}} | |
766 | ||
767 | Deletes the specified directory from the file system. | |
768 | ||
769 | ||
770 | \membersection{wxFileName::SameAs}\label{wxfilenamesameas} | |
771 | ||
772 | \constfunc{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
773 | ||
774 | Compares the filename using the rules of this platform. | |
775 | ||
776 | ||
777 | \membersection{wxFileName::SetCwd}\label{wxfilenamesetcwd} | |
778 | ||
779 | \func{bool}{SetCwd}{\void} | |
780 | ||
781 | \func{static bool}{SetCwd}{\param{const wxString\& }{cwd}} | |
782 | ||
783 | Changes the current working directory. | |
784 | ||
785 | ||
786 | \membersection{wxFileName::SetExt}\label{wxfilenamesetext} | |
787 | ||
788 | \func{void}{SetExt}{\param{const wxString\& }{ext}} | |
789 | ||
790 | Sets the extension of the file name. Setting an empty string | |
791 | as the extension will remove the extension resulting in a file | |
792 | name without a trailing dot, unlike a call to | |
793 | \helpref{SetEmptyExt}{wxfilenamesetemptyext}. | |
794 | ||
795 | \wxheading{See also} | |
796 | ||
797 | \helpref{SetEmptyExt}{wxfilenamesetemptyext} | |
798 | \helpref{ClearExt}{wxfilenameclearext} | |
799 | ||
800 | \membersection{wxFileName::SetEmptyExt}\label{wxfilenamesetemptyext} | |
801 | ||
802 | \func{void}{SetEmptyExt}{\void} | |
803 | ||
804 | Sets the extension of the file name to be an empty extension. | |
805 | This is different from having no extension at all as the file | |
806 | name will have a trailing dot after a call to this method. | |
807 | ||
808 | \wxheading{See also} | |
809 | ||
810 | \helpref{SetExt}{wxfilenamesetext} | |
811 | \helpref{ClearExt}{wxfilenameclearext} | |
812 | ||
813 | \membersection{wxFileName::SetFullName}\label{wxfilenamesetfullname} | |
814 | ||
815 | \func{void}{SetFullName}{\param{const wxString\& }{fullname}} | |
816 | ||
817 | The full name is the file name and extension (but without the path). | |
818 | ||
819 | ||
820 | \membersection{wxFileName::SetName}\label{wxfilenamesetname} | |
821 | ||
822 | \func{void}{SetName}{\param{const wxString\& }{name}} | |
823 | ||
824 | Sets the name part (without extension). | |
825 | ||
826 | \wxheading{See also} | |
827 | ||
828 | \helpref{SetFullName}{wxfilenamesetfullname} | |
829 | ||
830 | ||
831 | \membersection{wxFileName::SetTimes}\label{wxfilenamesettimes} | |
832 | ||
833 | \func{bool}{SetTimes}{\param{const wxDateTime* }{dtAccess}, \param{const wxDateTime* }{dtMod}, \param{const wxDateTime* }{dtCreate}} | |
834 | ||
835 | Sets the file creation and last access/modification times (any of the pointers may be NULL). | |
836 | ||
837 | ||
838 | \membersection{wxFileName::SetVolume}\label{wxfilenamesetvolume} | |
839 | ||
840 | \func{void}{SetVolume}{\param{const wxString\& }{volume}} | |
841 | ||
842 | Sets the volume specifier. | |
843 | ||
844 | ||
845 | \membersection{wxFileName::SplitPath}\label{wxfilenamesplitpath} | |
846 | ||
847 | \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}} | |
848 | ||
849 | \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}} | |
850 | ||
851 | \func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
852 | ||
853 | This function splits a full file name into components: the volume (with the | |
854 | first version) path (including the volume in the second version), the base name | |
855 | and the extension. Any of the output parameters ({\it volume}, {\it path}, | |
856 | {\it name} or {\it ext}) may be {\tt NULL} if you are not interested in the | |
857 | value of a particular component. Also, {\it fullpath} may be empty on entry. | |
858 | ||
859 | On return, {\it path} contains the file path (without the trailing separator), | |
860 | {\it name} contains the file name and {\it ext} contains the file extension | |
861 | without leading dot. All three of them may be empty if the corresponding | |
862 | component is. The old contents of the strings pointed to by these parameters | |
863 | will be overwritten in any case (if the pointers are not {\tt NULL}). | |
864 | ||
865 | Note that for a filename ``foo.'' the extension is present, as indicated by the | |
866 | trailing dot, but empty. If you need to cope with such cases, you should use | |
867 | \arg{hasExt} instead of relying on testing whether \arg{ext} is empty or not. | |
868 | ||
869 | ||
870 | \membersection{wxFileName::SplitVolume}\label{wxfilenamesplitvolume} | |
871 | ||
872 | \func{static void}{SplitVolume}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
873 | ||
874 | Splits the given \arg{fullpath} into the volume part (which may be empty) and | |
875 | the pure path part, not containing any volume. | |
876 | ||
877 | \wxheading{See also} | |
878 | ||
879 | \helpref{SplitPath}{wxfilenamesplitpath} | |
880 | ||
881 | ||
882 | \membersection{wxFileName::Touch}\label{wxfilenametouch} | |
883 | ||
884 | \func{bool}{Touch}{\void} | |
885 | ||
886 | Sets the access and modification times to the current moment. | |
887 | ||
888 | ||
889 | \membersection{wxFileName::operator=}\label{wxfilenameoperatorassign} | |
890 | ||
891 | \func{wxFileName\& operator}{operator=}{\param{const wxFileName\& }{filename}} | |
892 | ||
893 | \func{wxFileName\& operator}{operator=}{\param{const wxString\& }{filename}} | |
894 | ||
895 | Assigns the new value to this filename object. | |
896 | ||
897 | ||
898 | \membersection{wxFileName::operator==}\label{wxfilenameoperatorequal} | |
899 | ||
900 | \constfunc{bool operator}{operator==}{\param{const wxFileName\& }{filename}} | |
901 | ||
902 | \constfunc{bool operator}{operator==}{\param{const wxString\& }{filename}} | |
903 | ||
904 | Returns {\tt true} if the filenames are equal. The string {\it filenames} is | |
905 | interpreted as a path in the native filename format. | |
906 | ||
907 | ||
908 | \membersection{wxFileName::operator!=}\label{wxfilenameoperatornotequal} | |
909 | ||
910 | \constfunc{bool operator}{operator!=}{\param{const wxFileName\& }{filename}} | |
911 | ||
912 | \constfunc{bool operator}{operator!=}{\param{const wxString\& }{filename}} | |
913 | ||
914 | Returns {\tt true} if the filenames are different. The string {\it filenames} | |
915 | is interpreted as a path in the native filename format. | |
916 |