]>
Commit | Line | Data |
---|---|---|
2569938d VZ |
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 | |
8795498c | 9 | %% License: wxWindows license |
2569938d VZ |
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 | |
fc2171bd | 17 | functions (and \helpref{wxWidgets functions}{filefunctions} wrapping them). |
2569938d | 18 | Second, it includes the functions for working with the files itself. Note that |
95c00185 | 19 | to change the file data you should use \helpref{wxFile}{wxfile} class instead. |
2569938d VZ |
20 | wxFileName provides functions for working with the file attributes. |
21 | ||
51cb1a65 RR |
22 | When working with directory names (i.e. without filename and extension) |
23 | make sure not to misuse the file name part of this class with the last | |
24 | directory. Instead initialize the wxFileName instance like this: | |
25 | ||
26 | \begin{verbatim} | |
27 | wxFileName dirname( wxT("C:\mydir"), wxEmptyString ); | |
28 | MyMethod( dirname.GetPath() ); | |
29 | \end{verbatim} | |
30 | ||
faa3bd94 RR |
31 | The same can be done using the static method \helpref{wxFileName::DirName}{wxfilenamedirname}: |
32 | ||
33 | \begin{verbatim} | |
34 | wxFileName dirname = wxFileName::DirName( wxT("C:\mydir") ); | |
35 | MyMethod( dirname.GetPath() ); | |
36 | \end{verbatim} | |
37 | ||
51cb1a65 | 38 | Accordingly, methods dealing with directories or directory names |
faa3bd94 | 39 | like \helpref{IsDirReadable}{wxfilenameisdirreadable} use |
51cb1a65 | 40 | \helpref{GetPath}{wxfilenamegetpath} whereas methods dealing |
faa3bd94 | 41 | with file names like \helpref{IsFileReadable}{wxfilenameisfilereadable} |
51cb1a65 RR |
42 | use \helpref{GetFullPath}{wxfilenamegetfullpath}. |
43 | ||
44 | If it is not known wether a string contains a directory name or | |
45 | a complete file name (such as when interpreting user input) you need to use | |
46 | the static function \helpref{wxFileName::DirExists}{wxfilenamedirexists} | |
faa3bd94 RR |
47 | (or its identical variants \helpref{wxDir::Exists}{wxdirexists} and |
48 | \helpref{wxDirExists}{functionwxdirexists}) and construct the wxFileName | |
49 | instance accordingly. This will only work if the directory actually exists, | |
50 | of course: | |
51cb1a65 RR |
51 | |
52 | \begin{verbatim} | |
53 | wxString user_input; | |
54 | // get input from user | |
55 | ||
56 | wxFileName fname; | |
57 | if (wxDirExists(user_input)) | |
58 | fname.AssignDir( user_input ); | |
59 | else | |
60 | fname.Assign( user_input ); | |
61 | \end{verbatim} | |
62 | ||
2569938d VZ |
63 | \wxheading{Derived from} |
64 | ||
65 | No base class | |
66 | ||
93ab511d VZ |
67 | \wxheading{Include files} |
68 | ||
69 | <wx/filename.h> | |
70 | ||
2569938d VZ |
71 | \wxheading{Data structures} |
72 | ||
73 | Many wxFileName methods accept the path format argument which is by\rtfsp | |
74 | {\tt wxPATH\_NATIVE} by default meaning to use the path format native for the | |
75 | current platform. | |
76 | ||
77 | The path format affects the operation of wxFileName functions in several ways: | |
78 | first and foremost, it defines the path separator character to use, but it also | |
79 | affects other things such as whether the path has the drive part or not. | |
80 | ||
81 | \begin{verbatim} | |
82 | enum wxPathFormat | |
83 | { | |
84 | wxPATH_NATIVE = 0, // the path format for the current platform | |
85 | wxPATH_UNIX, | |
f363e05c | 86 | wxPATH_BEOS = wxPATH_UNIX, |
2569938d VZ |
87 | wxPATH_MAC, |
88 | wxPATH_DOS, | |
f363e05c VZ |
89 | wxPATH_WIN = wxPATH_DOS, |
90 | wxPATH_OS2 = wxPATH_DOS, | |
2569938d VZ |
91 | wxPATH_VMS, |
92 | ||
f363e05c | 93 | wxPATH_MAX // Not a valid value for specifying path format |
2569938d VZ |
94 | } |
95 | \end{verbatim} | |
96 | ||
6f91bc33 VZ |
97 | \latexignore{\rtfignore{\wxheading{Function groups}}} |
98 | ||
5bb9aeb2 | 99 | |
f0e8a2d0 | 100 | \membersection{File name format}\label{filenameformat} |
6f91bc33 VZ |
101 | |
102 | wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OS | |
103 | and VMS formats. Although these formats are quite different, wxFileName tries | |
2edb0bde | 104 | to treat them all in the same generic way. It supposes that all file names |
6f91bc33 VZ |
105 | consist of the following parts: the volume (also known as drive under Windows |
106 | or device under VMS), the path which is a sequence of directory names separated | |
107 | by the \helpref{path separators}{wxfilenamegetpathseparators} and the full | |
108 | filename itself which, in turn, is composed from the base file name and the | |
109 | extension. All of the individual components of the file name may be empty and, | |
110 | for example, the volume name is always empty under Unix, but if they are all | |
111 | empty simultaneously, the filename object is considered to be in an invalid | |
0894707e | 112 | state and \helpref{IsOk}{wxfilenameisok} returns {\tt false} for it. |
6f91bc33 VZ |
113 | |
114 | File names can be case-sensitive or not, the function\rtfsp | |
115 | \helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this. | |
116 | ||
47ce5c4a VZ |
117 | The rules for determining whether the file name is absolute or relative also |
118 | depend on the file name format and the only portable way to answer this | |
119 | question is to use \helpref{IsAbsolute}{wxfilenameisabsolute} or\rtfsp | |
120 | \helpref{IsRelative}{wxfilenameisrelative} method. Note that on Windows, "X:" | |
121 | refers to the current working directory on drive X. Therefore, a wxFileName | |
122 | instance constructed from for example "X:dir/file.ext" treats the portion | |
123 | beyond drive separator as being relative to that directory. | |
124 | ||
125 | To ensure that the filename is absolute, you may use\rtfsp | |
126 | \helpref{MakeAbsolute}{wxfilenamemakeabsolute}. There is also an inverse | |
127 | function \helpref{MakeRelativeTo}{wxfilenamemakerelativeto} which undoes | |
128 | what \helpref{Normalize(wxPATH\_NORM\_DOTS)}{wxfilenamenormalize} does. | |
6f91bc33 VZ |
129 | |
130 | Other functions returning information about the file format provided by this | |
131 | class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp | |
2db991f4 | 132 | \helpref{IsPathSeparator}{wxfilenameispathseparator}. |
6f91bc33 | 133 | |
5bb9aeb2 | 134 | |
f0e8a2d0 | 135 | \membersection{File name construction}\label{filenameconstruction} |
6f91bc33 | 136 | |
3ff07edb RR |
137 | You can initialize a wxFileName instance using one of the following functions: |
138 | ||
139 | \helpref{wxFileName constructors}{wxfilenamewxfilename}\\ | |
140 | \helpref{Assign}{wxfilenameassign}\\ | |
141 | \helpref{AssignCwd}{wxfilenameassigncwd}\\ | |
142 | \helpref{AssignDir}{wxfilenameassigndir}\\ | |
143 | \helpref{AssignHomeDir}{wxfilenameassignhomedir}\\ | |
144 | \helpref{AssignHomeTempFileName}{wxfilenameassigntempfilename}\\ | |
23fb9116 VZ |
145 | \helpref{DirName}{wxfilenamedirname}\\ |
146 | \helpref{FileName}{wxfilenamefilename}\\ | |
3ff07edb | 147 | \helpref{operator $=$}{wxfilenameoperatorassign} |
6f91bc33 | 148 | |
5bb9aeb2 | 149 | |
f0e8a2d0 | 150 | \membersection{File tests}\label{filetests} |
6f91bc33 | 151 | |
47ce5c4a VZ |
152 | Before doing other tests, you should use \helpref{IsOk}{wxfilenameisok} to |
153 | verify that the filename is well defined. If it is,\rtfsp | |
154 | \helpref{FileExists}{wxfilenamefileexists} can be used to test whether a file | |
155 | with such name exists and \helpref{DirExists}{wxfilenamedirexists} can be used | |
156 | to test for directory existence. | |
6f91bc33 VZ |
157 | |
158 | File names should be compared using \helpref{SameAs}{wxfilenamesameas} method | |
3ff07edb RR |
159 | or \helpref{operator $==$}{wxfilenameoperatorequal}. |
160 | ||
161 | For testing basic access modes, you can use: | |
162 | ||
163 | \helpref{IsDirWritable}{wxfilenameisdirwritable}\\ | |
164 | \helpref{IsDirReadable}{wxfilenameisdirreadable}\\ | |
165 | \helpref{IsFileWritable}{wxfilenameisfilewritable}\\ | |
166 | \helpref{IsFileReadable}{wxfilenameisfilereadable}\\ | |
167 | \helpref{IsFileExecutable}{wxfilenameisfileexecutable} | |
6f91bc33 | 168 | |
5bb9aeb2 | 169 | |
f0e8a2d0 | 170 | \membersection{File name components}\label{filenamecomponents} |
6f91bc33 | 171 | |
2458d90b VZ |
172 | These functions allow to examine and modify the individual directories of the |
173 | path: | |
6f91bc33 VZ |
174 | |
175 | \helpref{AppendDir}{wxfilenameappenddir}\\ | |
176 | \helpref{InsertDir}{wxfilenameinsertdir}\\ | |
177 | \helpref{GetDirCount}{wxfilenamegetdircount} | |
178 | \helpref{PrependDir}{wxfilenameprependdir}\\ | |
2458d90b VZ |
179 | \helpref{RemoveDir}{wxfilenameremovedir}\\ |
180 | \helpref{RemoveLastDir}{wxfilenameremovelastdir} | |
6f91bc33 VZ |
181 | |
182 | To change the components of the file name individually you can use the | |
183 | following functions: | |
184 | ||
185 | \helpref{GetExt}{wxfilenamegetext}\\ | |
186 | \helpref{GetName}{wxfilenamegetname}\\ | |
187 | \helpref{GetVolume}{wxfilenamegetvolume}\\ | |
188 | \helpref{HasExt}{wxfilenamehasext}\\ | |
189 | \helpref{HasName}{wxfilenamehasname}\\ | |
190 | \helpref{HasVolume}{wxfilenamehasvolume}\\ | |
191 | \helpref{SetExt}{wxfilenamesetext}\\ | |
0b40f3d8 RR |
192 | \helpref{ClearExt}{wxfilenameclearext}\\ |
193 | \helpref{SetEmptyExt}{wxfilenamesetemptyext}\\ | |
6f91bc33 VZ |
194 | \helpref{SetName}{wxfilenamesetname}\\ |
195 | \helpref{SetVolume}{wxfilenamesetvolume}\\ | |
196 | ||
5bb9aeb2 | 197 | |
f0e8a2d0 | 198 | \membersection{Operations}\label{filenameoperations} |
6f91bc33 VZ |
199 | |
200 | These methods allow to work with the file creation, access and modification | |
6dbb903b VZ |
201 | times. Note that not all filesystems under all platforms implement these times |
202 | in the same way. For example, the access time under Windows has a resolution of | |
203 | one day (so it is really the access date and not time). The access time may be | |
204 | updated when the file is executed or not depending on the platform. | |
6f91bc33 VZ |
205 | |
206 | \helpref{GetModificationTime}{wxfilenamegetmodificationtime}\\ | |
207 | \helpref{GetTimes}{wxfilenamegettimes}\\ | |
208 | \helpref{SetTimes}{wxfilenamesettimes}\\ | |
209 | \helpref{Touch}{wxfilenametouch} | |
210 | ||
211 | Other file system operations functions are: | |
212 | ||
213 | \helpref{Mkdir}{wxfilenamemkdir}\\ | |
214 | \helpref{Rmdir}{wxfilenamermdir} | |
215 | ||
2569938d VZ |
216 | \latexignore{\rtfignore{\wxheading{Members}}} |
217 | ||
5bb9aeb2 | 218 | |
6f91bc33 | 219 | \membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename} |
2569938d VZ |
220 | |
221 | \func{}{wxFileName}{\void} | |
222 | ||
223 | Default constructor. | |
224 | ||
2569938d VZ |
225 | \func{}{wxFileName}{\param{const wxFileName\& }{filename}} |
226 | ||
227 | Copy constructor. | |
228 | ||
2569938d VZ |
229 | \func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
230 | ||
95c00185 | 231 | Constructor taking a full filename. If it terminates with a '/', a directory path |
2edb0bde | 232 | is constructed (the name will be empty), otherwise a file name and |
95c00185 | 233 | extension are extracted from it. |
2569938d | 234 | |
2569938d VZ |
235 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
236 | ||
6f91bc33 | 237 | Constructor from a directory name and a file name. |
2569938d VZ |
238 | |
239 | \func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
240 | ||
95c00185 | 241 | Constructor from a directory name, base file name and extension. |
81f25632 VZ |
242 | |
243 | \func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
244 | ||
95c00185 | 245 | Constructor from a volume name, a directory name, base file name and extension. |
2569938d | 246 | |
5bb9aeb2 | 247 | |
2569938d VZ |
248 | \membersection{wxFileName::AppendDir}\label{wxfilenameappenddir} |
249 | ||
250 | \func{void}{AppendDir}{\param{const wxString\& }{dir}} | |
251 | ||
5bb9aeb2 VZ |
252 | Appends a directory component to the path. This component should contain a |
253 | single directory name level, i.e. not contain any path or volume separators nor | |
254 | should it be empty, otherwise the function does nothing (and generates an | |
255 | assert failure in debug build). | |
256 | ||
2569938d VZ |
257 | |
258 | \membersection{wxFileName::Assign}\label{wxfilenameassign} | |
259 | ||
260 | \func{void}{Assign}{\param{const wxFileName\& }{filepath}} | |
261 | ||
2569938d VZ |
262 | \func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
263 | ||
dfecbee5 VZ |
264 | \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}} |
265 | ||
2569938d VZ |
266 | \func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
267 | ||
2569938d VZ |
268 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
269 | ||
2569938d VZ |
270 | \func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
271 | ||
95c00185 | 272 | Creates the file name from various combinations of data. |
2569938d | 273 | |
5bb9aeb2 | 274 | |
2569938d VZ |
275 | \membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd} |
276 | ||
f363e05c | 277 | \func{static void}{AssignCwd}{\param{const wxString\& }{volume = wxEmptyString}} |
6f91bc33 VZ |
278 | |
279 | Makes this object refer to the current working directory on the specified | |
280 | volume (or current volume if {\it volume} is empty). | |
2569938d | 281 | |
6f91bc33 | 282 | \wxheading{See also} |
2569938d | 283 | |
6f91bc33 | 284 | \helpref{GetCwd}{wxfilenamegetcwd} |
2569938d | 285 | |
5bb9aeb2 | 286 | |
2569938d VZ |
287 | \membersection{wxFileName::AssignDir}\label{wxfilenameassigndir} |
288 | ||
289 | \func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
290 | ||
95c00185 | 291 | Sets this file name object to the given directory name. The name and extension |
81f25632 | 292 | will be empty. |
2569938d | 293 | |
5bb9aeb2 | 294 | |
2569938d VZ |
295 | \membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir} |
296 | ||
297 | \func{void}{AssignHomeDir}{\void} | |
298 | ||
95c00185 | 299 | Sets this file name object to the home directory. |
2569938d | 300 | |
5bb9aeb2 | 301 | |
2569938d VZ |
302 | \membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename} |
303 | ||
df22f860 | 304 | \func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} |
2569938d | 305 | |
ade35f11 VZ |
306 | The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to |
307 | create a temporary file and sets this object to the name of the file. If a | |
308 | temporary file couldn't be created, the object is put into the\rtfsp | |
309 | \helpref{invalid}{wxfilenameisok} state. | |
2569938d | 310 | |
5bb9aeb2 | 311 | |
2569938d VZ |
312 | \membersection{wxFileName::Clear}\label{wxfilenameclear} |
313 | ||
314 | \func{void}{Clear}{\void} | |
315 | ||
ade35f11 VZ |
316 | Reset all components to default, uninitialized state. |
317 | ||
5bb9aeb2 | 318 | |
0b40f3d8 RR |
319 | \membersection{wxFileName::ClearExt}\label{wxfilenameclearext} |
320 | ||
321 | \func{void}{SetClearExt}{\void} | |
322 | ||
323 | Removes the extension from the file name resulting in a | |
324 | file name with no trailing dot. | |
325 | ||
326 | \wxheading{See also} | |
327 | ||
328 | \helpref{SetExt}{wxfilenamesetext} | |
329 | \helpref{SetEmptyExt}{wxfilenamesetemptyext} | |
330 | ||
02a3b391 | 331 | \membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename} |
ade35f11 | 332 | |
df22f860 | 333 | \func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}} |
ade35f11 VZ |
334 | |
335 | Returns a temporary file name starting with the given {\it prefix}. If | |
336 | the {\it prefix} is an absolute path, the temporary file is created in this | |
337 | directory, otherwise it is created in the default system directory for the | |
338 | temporary files or in the current directory. | |
2569938d | 339 | |
df22f860 VZ |
340 | If the function succeeds, the temporary file is actually created. If\rtfsp |
341 | {\it fileTemp} is not {\tt NULL}, this file will be opened using the name of | |
342 | the temporary file. When possible, this is done in an atomic way ensuring that | |
343 | no race condition occurs between the temporary file name generation and opening | |
344 | it which could often lead to security compromise on the multiuser systems. | |
345 | If {\it fileTemp} is {\tt NULL}, the file is only created, but not opened. | |
346 | ||
347 | Under Unix, the temporary file will have read and write permissions for the | |
348 | owner only to minimize the security problems. | |
349 | ||
350 | \wxheading{Parameters} | |
351 | ||
352 | \docparam{prefix}{Prefix to use for the temporary file name construction} | |
353 | ||
354 | \docparam{fileTemp}{The file to open or {\tt NULL} to just get the name} | |
ade35f11 VZ |
355 | |
356 | \wxheading{Return value} | |
357 | ||
358 | The full temporary file name or an empty string on error. | |
2569938d | 359 | |
5bb9aeb2 | 360 | |
2569938d VZ |
361 | \membersection{wxFileName::DirExists}\label{wxfilenamedirexists} |
362 | ||
8e41796c | 363 | \constfunc{bool}{DirExists}{\void} |
2569938d | 364 | |
8e41796c | 365 | \func{static bool}{DirExists}{\param{const wxString\& }{dir}} |
2569938d | 366 | |
f363e05c | 367 | Returns {\tt true} if the directory with this name exists. |
2569938d | 368 | |
5bb9aeb2 | 369 | |
2569938d VZ |
370 | \membersection{wxFileName::DirName}\label{wxfilenamedirname} |
371 | ||
520200fd VZ |
372 | \func{static wxFileName}{DirName}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
373 | ||
374 | Returns the object corresponding to the directory with the given name. | |
375 | The {\it dir} parameter may have trailing path separator or not. | |
2569938d | 376 | |
95c00185 | 377 | |
5bb9aeb2 | 378 | |
2569938d VZ |
379 | \membersection{wxFileName::FileExists}\label{wxfilenamefileexists} |
380 | ||
8e41796c | 381 | \constfunc{bool}{FileExists}{\void} |
2569938d | 382 | |
8e41796c | 383 | \func{static bool}{FileExists}{\param{const wxString\& }{file}} |
2569938d | 384 | |
f363e05c | 385 | Returns {\tt true} if the file with this name exists. |
2569938d | 386 | |
8e41796c VZ |
387 | \wxheading{See also} |
388 | ||
389 | \helpref{DirExists}{wxfilenamedirexists} | |
390 | ||
520200fd | 391 | |
5bb9aeb2 | 392 | |
2569938d VZ |
393 | \membersection{wxFileName::FileName}\label{wxfilenamefilename} |
394 | ||
520200fd VZ |
395 | \func{static wxFileName}{FileName}{\param{const wxString\& }{file}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
396 | ||
397 | Returns the file name object corresponding to the given {\it file}. This | |
398 | function exists mainly for symmetry with \helpref{DirName}{wxfilenamedirname}. | |
2569938d | 399 | |
2569938d | 400 | |
5bb9aeb2 | 401 | |
2569938d VZ |
402 | \membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd} |
403 | ||
f363e05c | 404 | \func{static wxString}{GetCwd}{\param{const wxString\& }{volume = ""}} |
6f91bc33 | 405 | |
95c00185 | 406 | Retrieves the value of the current working directory on the specified volume. If |
43e8916f | 407 | the volume is empty, the program's current working directory is returned for the |
6f91bc33 VZ |
408 | current volume. |
409 | ||
410 | \wxheading{Return value} | |
411 | ||
412 | The string containing the current working directory or an empty string on | |
413 | error. | |
2569938d | 414 | |
6f91bc33 VZ |
415 | \wxheading{See also} |
416 | ||
417 | \helpref{AssignCwd}{wxfilenameassigncwd} | |
2569938d | 418 | |
5bb9aeb2 | 419 | |
2569938d VZ |
420 | \membersection{wxFileName::GetDirCount}\label{wxfilenamegetdircount} |
421 | ||
422 | \constfunc{size\_t}{GetDirCount}{\void} | |
423 | ||
95c00185 | 424 | Returns the number of directories in the file name. |
2569938d | 425 | |
5bb9aeb2 | 426 | |
2569938d VZ |
427 | \membersection{wxFileName::GetDirs}\label{wxfilenamegetdirs} |
428 | ||
429 | \constfunc{const wxArrayString\&}{GetDirs}{\void} | |
430 | ||
95c00185 | 431 | Returns the directories in string array form. |
2569938d | 432 | |
5bb9aeb2 | 433 | |
2569938d VZ |
434 | \membersection{wxFileName::GetExt}\label{wxfilenamegetext} |
435 | ||
436 | \constfunc{wxString}{GetExt}{\void} | |
437 | ||
95c00185 | 438 | Returns the file name extension. |
2569938d | 439 | |
5bb9aeb2 | 440 | |
f363e05c VZ |
441 | \membersection{wxFileName::GetForbiddenChars}\label{wxfilenamegetforbiddenchars} |
442 | ||
443 | \func{static wxString}{GetForbiddenChars}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
444 | ||
445 | Returns the characters that can't be used in filenames and directory names for the specified format. | |
446 | ||
5bb9aeb2 | 447 | |
2569938d VZ |
448 | \membersection{wxFileName::GetFormat}\label{wxfilenamegetformat} |
449 | ||
f363e05c | 450 | \func{static wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 451 | |
95c00185 | 452 | Returns the canonical path format for this platform. |
2569938d | 453 | |
5bb9aeb2 | 454 | |
2569938d VZ |
455 | \membersection{wxFileName::GetFullName}\label{wxfilenamegetfullname} |
456 | ||
457 | \constfunc{wxString}{GetFullName}{\void} | |
458 | ||
95c00185 | 459 | Returns the full name (including extension but excluding directories). |
2569938d | 460 | |
5bb9aeb2 | 461 | |
2569938d VZ |
462 | \membersection{wxFileName::GetFullPath}\label{wxfilenamegetfullpath} |
463 | ||
464 | \constfunc{wxString}{GetFullPath}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
465 | ||
95c00185 | 466 | Returns the full path with name and extension. |
2569938d | 467 | |
5bb9aeb2 | 468 | |
2569938d VZ |
469 | \membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir} |
470 | ||
f363e05c | 471 | \func{static wxString}{GetHomeDir}{\void} |
2569938d | 472 | |
95c00185 | 473 | Returns the home directory. |
2569938d | 474 | |
5bb9aeb2 | 475 | |
2569938d VZ |
476 | \membersection{wxFileName::GetLongPath}\label{wxfilenamegetlongpath} |
477 | ||
478 | \constfunc{wxString}{GetLongPath}{\void} | |
479 | ||
480 | Return the long form of the path (returns identity on non-Windows platforms) | |
481 | ||
5bb9aeb2 | 482 | |
2569938d VZ |
483 | \membersection{wxFileName::GetModificationTime}\label{wxfilenamegetmodificationtime} |
484 | ||
485 | \constfunc{wxDateTime}{GetModificationTime}{\void} | |
486 | ||
95c00185 | 487 | Returns the last time the file was last modified. |
2569938d | 488 | |
5bb9aeb2 | 489 | |
2569938d VZ |
490 | \membersection{wxFileName::GetName}\label{wxfilenamegetname} |
491 | ||
492 | \constfunc{wxString}{GetName}{\void} | |
493 | ||
4e43c815 VZ |
494 | Returns the name part of the filename (without extension). |
495 | ||
496 | \wxheading{See also} | |
497 | ||
498 | \helpref{GetFullName}{wxfilenamegetfullname} | |
499 | ||
2569938d | 500 | |
5bb9aeb2 | 501 | |
2569938d VZ |
502 | \membersection{wxFileName::GetPath}\label{wxfilenamegetpath} |
503 | ||
93fa67c0 | 504 | \constfunc{wxString}{GetPath}{\param{int }{flags = {\tt wxPATH\_GET\_VOLUME}}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 505 | |
95c00185 | 506 | Returns the path part of the filename (without the name or extension). The |
33b97389 | 507 | possible flags values are: |
2569938d | 508 | |
d1853d47 | 509 | \twocolwidtha{5cm} |
33b97389 | 510 | \begin{twocollist}\itemsep=0pt |
d1853d47 | 511 | \twocolitem{{\bf wxPATH\_GET\_VOLUME}}{Return the path with the volume (does |
93fa67c0 VZ |
512 | nothing for the filename formats without volumes), otherwise the path without |
513 | volume part is returned.} | |
d1853d47 | 514 | \twocolitem{{\bf wxPATH\_GET\_SEPARATOR}}{Return the path with the trailing |
33b97389 VZ |
515 | separator, if this flag is not given there will be no separator at the end of |
516 | the path.} | |
517 | \end{twocollist} | |
518 | ||
5bb9aeb2 | 519 | |
33b97389 VZ |
520 | \membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator} |
521 | ||
f363e05c | 522 | \func{static wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} |
33b97389 | 523 | |
95c00185 | 524 | Returns the usually used path separator for this format. For all formats but |
33b97389 VZ |
525 | {\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there |
526 | are two of them and the native one, i.e. the backslash is returned by this | |
527 | method. | |
528 | ||
529 | \wxheading{See also} | |
530 | ||
531 | \helpref{GetPathSeparators}{wxfilenamegetpathseparators} | |
2569938d | 532 | |
5bb9aeb2 | 533 | |
2569938d VZ |
534 | \membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators} |
535 | ||
f363e05c | 536 | \func{static wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 537 | |
95c00185 | 538 | Returns the string containing all the path separators for this format. For all |
33b97389 | 539 | formats but {\tt wxPATH\_DOS} this string contains only one character but for |
7af3ca16 | 540 | DOS and Windows both {\tt '/'} and {\tt '\textbackslash'} may be used as |
33b97389 VZ |
541 | separators. |
542 | ||
543 | \wxheading{See also} | |
2569938d | 544 | |
33b97389 | 545 | \helpref{GetPathSeparator}{wxfilenamegetpathseparator} |
2569938d | 546 | |
5bb9aeb2 | 547 | |
f1e77933 VZ |
548 | \membersection{wxFileName::GetPathTerminators}\label{wxfilenamegetpathterminators} |
549 | ||
550 | \func{static wxString}{GetPathTerminators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
551 | ||
552 | Returns the string of characters which may terminate the path part. This is the | |
553 | same as \helpref{GetPathSeparators}{wxfilenamegetpathseparators} except for VMS | |
554 | path format where $]$ is used at the end of the path part. | |
555 | ||
556 | ||
8b4b9395 VZ |
557 | \membersection{wxFileName::GetPathWithSep}\label{wxfilenamegetpathwithsep} |
558 | ||
559 | \constfunc{wxString}{GetPathWithSep}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
560 | ||
561 | Returns the path with the trailing separator, useful for appending the name to | |
562 | the given path. | |
563 | ||
564 | This is the same as calling \helpref{GetPath}{wxfilenamegetpath} | |
565 | \texttt{(wxPATH\_GET\_VOLUME | wxPATH\_GET\_SEPARATOR, format)}. | |
566 | ||
567 | ||
2569938d VZ |
568 | \membersection{wxFileName::GetShortPath}\label{wxfilenamegetshortpath} |
569 | ||
570 | \constfunc{wxString}{GetShortPath}{\void} | |
571 | ||
95c00185 | 572 | Return the short form of the path (returns identity on non-Windows platforms). |
2569938d | 573 | |
5bb9aeb2 | 574 | |
23b8a262 JS |
575 | \membersection{wxFileName::GetSize}\label{wxfilenamegetsize} |
576 | ||
577 | \constfunc{wxULongLong}{GetSize}{\void} | |
578 | ||
579 | \func{static wxULongLong}{GetSize}{\param{const wxString\& }{filename}} | |
580 | ||
581 | Returns the size of this file (first form) or the size of the given file (second form). | |
582 | If the file does not exist or its size could not be read (because e.g. the file is locked | |
583 | by another process) the returned value is {\tt wxInvalidSize}. | |
584 | ||
585 | ||
586 | \membersection{wxFileName::GetHumanReadableSize}\label{wxfilenamegethumanreadablesize} | |
587 | ||
588 | \constfunc{wxString}{GetHumanReadableSize}{\param{const wxString\& }{failmsg = "Not available"}, \param{int }{precision = 1}} | |
589 | ||
590 | \func{static wxString}{GetHumanReadableSize}{\param{const wxULongLong\& }{bytes}, \param{const wxString\& }{nullsize = "Not available"}, \param{int }{precision = 1}} | |
591 | ||
592 | Returns the size of this file (first form) or the given number of bytes (second form) | |
593 | in a human-readable form. | |
594 | ||
595 | If the size could not be retrieved the {\tt failmsg} string is returned (first form). | |
596 | If {\tt bytes} is {\tt wxInvalidSize} or zero, then {\tt nullsize} is returned (second form). | |
597 | ||
598 | In case of success, the returned string is a floating-point number with {\tt precision} decimal digits | |
599 | followed by the size unit (B, kB, MB, GB, TB: respectively bytes, kilobytes, megabytes, gigabytes, terabytes). | |
600 | ||
601 | ||
8d7d6dea JS |
602 | \membersection{wxFileName::GetTempDir}\label{wxfilenamegettempdir} |
603 | ||
604 | \func{static wxString}{GetTempDir}{\void} | |
605 | ||
606 | Returns the directory used for temporary files. | |
607 | ||
608 | ||
2569938d VZ |
609 | \membersection{wxFileName::GetTimes}\label{wxfilenamegettimes} |
610 | ||
6dbb903b | 611 | \constfunc{bool}{GetTimes}{\param{wxDateTime* }{dtAccess}, \param{wxDateTime* }{dtMod}, \param{wxDateTime* }{dtCreate}} |
2569938d | 612 | |
95c00185 | 613 | Returns the last access, last modification and creation times. The last access |
ebb39671 VZ |
614 | time is updated whenever the file is read or written (or executed in the case |
615 | of Windows), last modification time is only changed when the file is written | |
616 | to. Finally, the creation time is indeed the time when the file was created | |
617 | under Windows and the inode change time under Unix (as it is impossible to | |
618 | retrieve the real file creation time there anyhow) which can also be changed | |
619 | by many operations after the file creation. | |
2569938d | 620 | |
51cb1a65 RR |
621 | If no filename or extension is specified in this instance of wxFileName |
622 | (and therefore \helpref{IsDir}{wxfilenameisdir} returns {\tt true}) then | |
623 | this function will return the directory times of the path specified by | |
624 | \helpref{GetPath}{wxfilenamegetpath}, otherwise the file times of the | |
625 | file specified by \helpref{GetFullPath}{wxfilenamegetfullpath}. | |
626 | ||
95c00185 | 627 | Any of the pointers may be {\tt NULL} if the corresponding time is not |
ebb39671 VZ |
628 | needed. |
629 | ||
630 | \wxheading{Return value} | |
631 | ||
0894707e | 632 | {\tt true} on success, {\tt false} if we failed to retrieve the times. |
2569938d | 633 | |
5bb9aeb2 | 634 | |
2569938d VZ |
635 | \membersection{wxFileName::GetVolume}\label{wxfilenamegetvolume} |
636 | ||
637 | \constfunc{wxString}{GetVolume}{\void} | |
638 | ||
f70c0443 | 639 | Returns the string containing the volume for this file name, empty if it |
ebb39671 VZ |
640 | doesn't have one or if the file system doesn't support volumes at all (for |
641 | example, Unix). | |
2569938d | 642 | |
5bb9aeb2 | 643 | |
2569938d VZ |
644 | \membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator} |
645 | ||
f363e05c | 646 | \func{static wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 647 | |
95c00185 | 648 | Returns the string separating the volume from the path for this format. |
2569938d | 649 | |
5bb9aeb2 | 650 | |
2569938d VZ |
651 | \membersection{wxFileName::HasExt}\label{wxfilenamehasext} |
652 | ||
653 | \constfunc{bool}{HasExt}{\void} | |
654 | ||
f363e05c | 655 | Returns {\tt true} if an extension is present. |
2569938d | 656 | |
5bb9aeb2 | 657 | |
2569938d VZ |
658 | \membersection{wxFileName::HasName}\label{wxfilenamehasname} |
659 | ||
660 | \constfunc{bool}{HasName}{\void} | |
661 | ||
f363e05c | 662 | Returns {\tt true} if a name is present. |
2569938d | 663 | |
5bb9aeb2 | 664 | |
2569938d VZ |
665 | \membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume} |
666 | ||
667 | \constfunc{bool}{HasVolume}{\void} | |
668 | ||
f363e05c | 669 | Returns {\tt true} if a volume specifier is present. |
2569938d | 670 | |
5bb9aeb2 | 671 | |
2569938d VZ |
672 | \membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir} |
673 | ||
2458d90b | 674 | \func{void}{InsertDir}{\param{size\_t }{before}, \param{const wxString\& }{dir}} |
2569938d | 675 | |
5bb9aeb2 VZ |
676 | Inserts a directory component before the zero-based position in the directory |
677 | list. Please see \helpref{AppendDir}{wxfilenameappenddir} for important notes. | |
678 | ||
2569938d VZ |
679 | |
680 | \membersection{wxFileName::IsAbsolute}\label{wxfilenameisabsolute} | |
681 | ||
682 | \func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
683 | ||
f363e05c | 684 | Returns {\tt true} if this filename is absolute. |
2569938d | 685 | |
5bb9aeb2 | 686 | |
2569938d VZ |
687 | \membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive} |
688 | ||
f363e05c | 689 | \func{static bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 690 | |
f363e05c | 691 | Returns {\tt true} if the file names of this type are case-sensitive. |
2569938d | 692 | |
5bb9aeb2 | 693 | |
3ff07edb RR |
694 | \membersection{wxFileName::IsDirReadable}\label{wxfilenameisdirreadable} |
695 | ||
696 | \constfunc{bool}{IsDirReadable}{\void} | |
697 | ||
698 | \func{static bool}{IsDirReadable}{\param{const wxString\& }{dir}} | |
699 | ||
700 | Returns {\tt true} if the directory component of this instance (or given \arg{dir}) | |
701 | is an existing directory and this process has read permissions on it. | |
702 | Read permissions on a directory mean that you can list the directory contents but it | |
703 | doesn't imply that you have read permissions on the files contained. | |
704 | ||
705 | ||
706 | \membersection{wxFileName::IsDirWritable}\label{wxfilenameisdirwritable} | |
707 | ||
708 | \constfunc{bool}{IsDirWritable}{\void} | |
709 | ||
710 | \func{static bool}{IsDirWritable}{\param{const wxString\& }{dir}} | |
711 | ||
712 | Returns {\tt true} if the directory component of this instance (or given \arg{dir}) | |
713 | is an existing directory and this process has write permissions on it. | |
714 | Write permissions on a directory mean that you can create new files in the directory. | |
715 | ||
716 | ||
717 | \membersection{wxFileName::IsFileExecutable}\label{wxfilenameisfileexecutable} | |
718 | ||
719 | \constfunc{bool}{IsFileExecutable}{\void} | |
720 | ||
721 | \func{static bool}{IsFileExecutable}{\param{const wxString\& }{file}} | |
722 | ||
723 | Returns {\tt true} if a file with this name exists and if this process has execute permissions on it. | |
724 | ||
725 | ||
726 | \membersection{wxFileName::IsFileReadable}\label{wxfilenameisfilereadable} | |
727 | ||
728 | \constfunc{bool}{IsFileReadable}{\void} | |
729 | ||
730 | \func{static bool}{IsFileReadable}{\param{const wxString\& }{file}} | |
731 | ||
732 | Returns {\tt true} if a file with this name exists and if this process has read permissions on it. | |
733 | ||
734 | ||
735 | \membersection{wxFileName::IsFileWritable}\label{wxfilenameisfilewritable} | |
736 | ||
737 | \constfunc{bool}{IsFileWritable}{\void} | |
738 | ||
739 | \func{static bool}{IsFileWritable}{\param{const wxString\& }{file}} | |
740 | ||
741 | Returns {\tt true} if a file with this name exists and if this process has write permissions on it. | |
742 | ||
743 | ||
2569938d VZ |
744 | \membersection{wxFileName::IsOk}\label{wxfilenameisok} |
745 | ||
746 | \constfunc{bool}{IsOk}{\void} | |
747 | ||
0894707e | 748 | Returns {\tt true} if the filename is valid, {\tt false} if it is not |
ade35f11 VZ |
749 | initialized yet. The assignment functions and |
750 | \helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized, | |
751 | invalid state (the former only do it on failure). | |
2569938d | 752 | |
5bb9aeb2 | 753 | |
2569938d VZ |
754 | \membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator} |
755 | ||
f363e05c | 756 | \func{static bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 757 | |
0894707e | 758 | Returns {\tt true} if the char is a path separator for this format. |
2569938d | 759 | |
5bb9aeb2 | 760 | |
2569938d VZ |
761 | \membersection{wxFileName::IsRelative}\label{wxfilenameisrelative} |
762 | ||
763 | \func{bool}{IsRelative}{\param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
764 | ||
0894707e | 765 | Returns {\tt true} if this filename is not absolute. |
2569938d | 766 | |
5bb9aeb2 | 767 | |
2db991f4 | 768 | \membersection{wxFileName::IsDir}\label{wxfilenameisdir} |
2569938d | 769 | |
2db991f4 | 770 | \constfunc{bool}{IsDir}{\void} |
2569938d | 771 | |
0894707e | 772 | Returns {\tt true} if this object represents a directory, {\tt false} otherwise |
2db991f4 VZ |
773 | (i.e. if it is a file). Note that this method doesn't test whether the |
774 | directory or file really exists, you should use | |
775 | \helpref{DirExists}{wxfilenamedirexists} or | |
776 | \helpref{FileExists}{wxfilenamefileexists} for this. | |
2569938d | 777 | |
5ab2950d JS |
778 | \membersection{wxFileName::MacFindDefaultTypeAndCreator}\label{wxfilenamemacfinddefaulttypeandcreator} |
779 | ||
780 | \func{static bool}{MacFindDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32* }{type}, \param{wxUint32* }{creator}} | |
781 | ||
782 | On Mac OS, gets the common type and creator for the given extension. | |
783 | ||
784 | \membersection{wxFileName::MacRegisterDefaultTypeAndCreator}\label{wxfilenamemacregisterdefaulttypeandcreator} | |
785 | ||
786 | \func{static void}{MacRegisterDefaultTypeAndCreator}{\param{const wxString\& }{ext}, \param{wxUint32 }{type}, \param{wxUint32 }{creator}} | |
787 | ||
788 | On Mac OS, registers application defined extensions and their default type and creator. | |
789 | ||
790 | \membersection{wxFileName::MacSetDefaultTypeAndCreator}\label{wxfilenamemacsetdefaulttypeandcreator} | |
791 | ||
792 | \func{bool}{MacSetDefaultTypeAndCreator}{\void} | |
793 | ||
794 | On Mac OS, looks up the appropriate type and creator from the registration and then sets it. | |
5bb9aeb2 | 795 | |
0894707e VS |
796 | \membersection{wxFileName::MakeAbsolute}\label{wxfilenamemakeabsolute} |
797 | ||
798 | \func{bool}{MakeAbsolute}{\param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
799 | ||
800 | Make the file name absolute. This is a shortcut for | |
801 | {\tt \helpref{Normalize}{wxfilenamenormalize}(wxPATH\_NORM\_DOTS | wxPATH\_NORM\_ABSOLUTE | wxPATH\_NORM\_TILDE, cwd, format)}. | |
802 | ||
803 | \wxheading{See also} | |
804 | ||
805 | \helpref{MakeRelativeTo}{wxfilenamemakerelativeto}, | |
806 | \helpref{Normalize}{wxfilenamenormalize}, | |
807 | \helpref{IsAbsolute}{wxfilenameisabsolute} | |
808 | ||
5bb9aeb2 | 809 | |
f7d886af VZ |
810 | \membersection{wxFileName::MakeRelativeTo}\label{wxfilenamemakerelativeto} |
811 | ||
f363e05c | 812 | \func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
f7d886af VZ |
813 | |
814 | This function tries to put this file name in a form relative to {\it pathBase}. | |
815 | In other words, it returns the file name which should be used to access this | |
816 | file if the current directory were {\it pathBase}. | |
817 | ||
818 | \docparam{pathBase}{the directory to use as root, current directory is used by | |
819 | default} | |
820 | ||
821 | \docparam{format}{the file name format, native by default} | |
822 | ||
823 | \wxheading{Return value} | |
824 | ||
0894707e | 825 | {\tt true} if the file name has been changed, {\tt false} if we failed to do |
f7d886af VZ |
826 | anything with it (currently this only happens if the file name is on a volume |
827 | different from the volume specified by {\it pathBase}). | |
828 | ||
829 | \wxheading{See also} | |
830 | ||
831 | \helpref{Normalize}{wxfilenamenormalize} | |
2569938d | 832 | |
5bb9aeb2 | 833 | |
2569938d VZ |
834 | \membersection{wxFileName::Mkdir}\label{wxfilenamemkdir} |
835 | ||
1527281e | 836 | \func{bool}{Mkdir}{\param{int }{perm = 0777}, \param{int }{flags = $0$}} |
2569938d | 837 | |
1527281e | 838 | \func{static bool}{Mkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}, \param{int }{flags = $0$}} |
2569938d | 839 | |
6f91bc33 | 840 | \docparam{dir}{the directory to create} |
2569938d | 841 | |
6f91bc33 VZ |
842 | \docparam{parm}{the permissions for the newly created directory} |
843 | ||
1527281e VZ |
844 | \docparam{flags}{if the flags contain {\tt wxPATH\_MKDIR\_FULL} flag, |
845 | try to create each directory in the path and also don't return an error | |
846 | if the target directory already exists.} | |
2569938d | 847 | |
6f91bc33 | 848 | \wxheading{Return value} |
2569938d | 849 | |
0894707e | 850 | Returns {\tt true} if the directory was successfully created, {\tt false} |
6f91bc33 | 851 | otherwise. |
2569938d | 852 | |
5bb9aeb2 | 853 | |
2569938d VZ |
854 | \membersection{wxFileName::Normalize}\label{wxfilenamenormalize} |
855 | ||
32a0d013 | 856 | \func{bool}{Normalize}{\param{int }{flags = wxPATH\_NORM\_ALL}, \param{const wxString\& }{cwd = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 857 | |
0894707e | 858 | Normalize the path. With the default flags value, the path will be |
2569938d | 859 | made absolute, without any ".." and "." and all environment |
0894707e VS |
860 | variables will be expanded in it. |
861 | ||
862 | \docparam{flags}{The kind of normalization to do with the file name. It can be | |
863 | any or-combination of the following constants: | |
d2c2afc9 | 864 | |
0894707e VS |
865 | \begin{twocollist} |
866 | \twocolitem{{\bf wxPATH\_NORM\_ENV\_VARS}}{replace env vars with their values} | |
bf7f7793 | 867 | \twocolitem{{\bf wxPATH\_NORM\_DOTS}}{squeeze all .. and . when possible; if there are too many .. and thus they cannot be all removed, \false will be returned} |
08890e27 | 868 | \twocolitem{{\bf wxPATH\_NORM\_CASE}}{if filesystem is case insensitive, transform to lower case} |
bf7f7793 | 869 | \twocolitem{{\bf wxPATH\_NORM\_ABSOLUTE}}{make the path absolute prepending \arg{cwd}} |
0894707e | 870 | \twocolitem{{\bf wxPATH\_NORM\_LONG}}{make the path the long form} |
21f60945 | 871 | \twocolitem{{\bf wxPATH\_NORM\_SHORTCUT}}{resolve if it is a shortcut (Windows only)} |
bf7f7793 | 872 | \twocolitem{{\bf wxPATH\_NORM\_TILDE}}{replace ~ and ~user (Unix only)} |
ef92f440 | 873 | \twocolitem{{\bf wxPATH\_NORM\_ALL}}{all of previous flags except \texttt{wxPATH\_NORM\_CASE}} |
0894707e | 874 | \end{twocollist} |
d2c2afc9 | 875 | }% |
0894707e VS |
876 | |
877 | \docparam{cwd}{If not empty, this directory will be used instead of current | |
bf7f7793 | 878 | working directory in normalization (see wxPATH\_NORM\_ABSOLUTE).} |
0894707e | 879 | |
bf7f7793 RR |
880 | \docparam{format}{The file name format to use when processing the paths, native by default.} |
881 | ||
882 | ||
883 | \wxheading{Return value} | |
884 | ||
885 | \true if normalization was successfully or \false otherwise. | |
2569938d | 886 | |
5bb9aeb2 | 887 | |
2569938d VZ |
888 | \membersection{wxFileName::PrependDir}\label{wxfilenameprependdir} |
889 | ||
890 | \func{void}{PrependDir}{\param{const wxString\& }{dir}} | |
891 | ||
5bb9aeb2 VZ |
892 | Prepends a directory to the file path. Please see |
893 | \helpref{AppendDir}{wxfilenameappenddir} for important notes. | |
894 | ||
895 | ||
2569938d VZ |
896 | |
897 | \membersection{wxFileName::RemoveDir}\label{wxfilenameremovedir} | |
898 | ||
2458d90b | 899 | \func{void}{RemoveDir}{\param{size\_t }{pos}} |
2569938d | 900 | |
2458d90b VZ |
901 | Removes the specified directory component from the path. |
902 | ||
903 | \wxheading{See also} | |
904 | ||
905 | \helpref{GetDirCount}{wxfilenamegetdircount} | |
906 | ||
907 | ||
908 | \membersection{wxFileName::RemoveLastDir}\label{wxfilenameremovelastdir} | |
909 | ||
910 | \func{void}{RemoveLastDir}{\void} | |
911 | ||
912 | Removes last directory component from the path. | |
2569938d | 913 | |
5bb9aeb2 | 914 | |
2569938d VZ |
915 | \membersection{wxFileName::Rmdir}\label{wxfilenamermdir} |
916 | ||
917 | \func{bool}{Rmdir}{\void} | |
918 | ||
6f91bc33 | 919 | \func{static bool}{Rmdir}{\param{const wxString\& }{dir}} |
2569938d | 920 | |
95c00185 | 921 | Deletes the specified directory from the file system. |
2569938d | 922 | |
5bb9aeb2 | 923 | |
2569938d VZ |
924 | \membersection{wxFileName::SameAs}\label{wxfilenamesameas} |
925 | ||
2b5f62a0 | 926 | \constfunc{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 927 | |
95c00185 | 928 | Compares the filename using the rules of this platform. |
2569938d | 929 | |
5bb9aeb2 | 930 | |
2569938d VZ |
931 | \membersection{wxFileName::SetCwd}\label{wxfilenamesetcwd} |
932 | ||
933 | \func{bool}{SetCwd}{\void} | |
934 | ||
6f91bc33 | 935 | \func{static bool}{SetCwd}{\param{const wxString\& }{cwd}} |
2569938d | 936 | |
95c00185 | 937 | Changes the current working directory. |
2569938d | 938 | |
5bb9aeb2 | 939 | |
2569938d VZ |
940 | \membersection{wxFileName::SetExt}\label{wxfilenamesetext} |
941 | ||
942 | \func{void}{SetExt}{\param{const wxString\& }{ext}} | |
943 | ||
0b40f3d8 RR |
944 | Sets the extension of the file name. Setting an empty string |
945 | as the extension will remove the extension resulting in a file | |
946 | name without a trailing dot, unlike a call to | |
947 | \helpref{SetEmptyExt}{wxfilenamesetemptyext}. | |
948 | ||
949 | \wxheading{See also} | |
950 | ||
951 | \helpref{SetEmptyExt}{wxfilenamesetemptyext} | |
952 | \helpref{ClearExt}{wxfilenameclearext} | |
953 | ||
954 | \membersection{wxFileName::SetEmptyExt}\label{wxfilenamesetemptyext} | |
955 | ||
956 | \func{void}{SetEmptyExt}{\void} | |
957 | ||
958 | Sets the extension of the file name to be an empty extension. | |
959 | This is different from having no extension at all as the file | |
960 | name will have a trailing dot after a call to this method. | |
961 | ||
962 | \wxheading{See also} | |
2569938d | 963 | |
0b40f3d8 RR |
964 | \helpref{SetExt}{wxfilenamesetext} |
965 | \helpref{ClearExt}{wxfilenameclearext} | |
5bb9aeb2 | 966 | |
2569938d VZ |
967 | \membersection{wxFileName::SetFullName}\label{wxfilenamesetfullname} |
968 | ||
969 | \func{void}{SetFullName}{\param{const wxString\& }{fullname}} | |
970 | ||
95c00185 | 971 | The full name is the file name and extension (but without the path). |
2569938d | 972 | |
5bb9aeb2 | 973 | |
2569938d VZ |
974 | \membersection{wxFileName::SetName}\label{wxfilenamesetname} |
975 | ||
976 | \func{void}{SetName}{\param{const wxString\& }{name}} | |
977 | ||
4e43c815 VZ |
978 | Sets the name part (without extension). |
979 | ||
980 | \wxheading{See also} | |
981 | ||
982 | \helpref{SetFullName}{wxfilenamesetfullname} | |
2569938d | 983 | |
5bb9aeb2 | 984 | |
2569938d VZ |
985 | \membersection{wxFileName::SetTimes}\label{wxfilenamesettimes} |
986 | ||
6dbb903b | 987 | \func{bool}{SetTimes}{\param{const wxDateTime* }{dtAccess}, \param{const wxDateTime* }{dtMod}, \param{const wxDateTime* }{dtCreate}} |
2569938d | 988 | |
95c00185 | 989 | Sets the file creation and last access/modification times (any of the pointers may be NULL). |
2569938d | 990 | |
5bb9aeb2 | 991 | |
2569938d VZ |
992 | \membersection{wxFileName::SetVolume}\label{wxfilenamesetvolume} |
993 | ||
994 | \func{void}{SetVolume}{\param{const wxString\& }{volume}} | |
995 | ||
95c00185 | 996 | Sets the volume specifier. |
2569938d | 997 | |
5bb9aeb2 | 998 | |
2569938d VZ |
999 | \membersection{wxFileName::SplitPath}\label{wxfilenamesplitpath} |
1000 | ||
dfecbee5 VZ |
1001 | \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}} |
1002 | ||
2bd25c5a | 1003 | \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}} |
2569938d | 1004 | |
2bd25c5a | 1005 | \func{static void}{SplitPath}{\param{const wxString\& }{fullpath}, \param{wxString* }{path}, \param{wxString* }{name}, \param{wxString* }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} |
2569938d | 1006 | |
2bd25c5a VZ |
1007 | This function splits a full file name into components: the volume (with the |
1008 | first version) path (including the volume in the second version), the base name | |
1009 | and the extension. Any of the output parameters ({\it volume}, {\it path}, | |
1010 | {\it name} or {\it ext}) may be {\tt NULL} if you are not interested in the | |
1011 | value of a particular component. Also, {\it fullpath} may be empty on entry. | |
1012 | ||
1013 | On return, {\it path} contains the file path (without the trailing separator), | |
1014 | {\it name} contains the file name and {\it ext} contains the file extension | |
1015 | without leading dot. All three of them may be empty if the corresponding | |
1016 | component is. The old contents of the strings pointed to by these parameters | |
1017 | will be overwritten in any case (if the pointers are not {\tt NULL}). | |
2569938d | 1018 | |
dfecbee5 VZ |
1019 | Note that for a filename ``foo.'' the extension is present, as indicated by the |
1020 | trailing dot, but empty. If you need to cope with such cases, you should use | |
1021 | \arg{hasExt} instead of relying on testing whether \arg{ext} is empty or not. | |
1022 | ||
5bb9aeb2 | 1023 | |
f1e77933 VZ |
1024 | \membersection{wxFileName::SplitVolume}\label{wxfilenamesplitvolume} |
1025 | ||
1026 | \func{static void}{SplitVolume}{\param{const wxString\& }{fullpath}, \param{wxString* }{volume}, \param{wxString* }{path}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} | |
1027 | ||
1028 | Splits the given \arg{fullpath} into the volume part (which may be empty) and | |
1029 | the pure path part, not containing any volume. | |
1030 | ||
1031 | \wxheading{See also} | |
1032 | ||
1033 | \helpref{SplitPath}{wxfilenamesplitpath} | |
1034 | ||
1035 | ||
2569938d VZ |
1036 | \membersection{wxFileName::Touch}\label{wxfilenametouch} |
1037 | ||
1038 | \func{bool}{Touch}{\void} | |
1039 | ||
95c00185 | 1040 | Sets the access and modification times to the current moment. |
2569938d | 1041 | |
5bb9aeb2 | 1042 | |
2569938d VZ |
1043 | \membersection{wxFileName::operator=}\label{wxfilenameoperatorassign} |
1044 | ||
1045 | \func{wxFileName\& operator}{operator=}{\param{const wxFileName\& }{filename}} | |
1046 | ||
2569938d VZ |
1047 | \func{wxFileName\& operator}{operator=}{\param{const wxString\& }{filename}} |
1048 | ||
6f91bc33 | 1049 | Assigns the new value to this filename object. |
2569938d | 1050 | |
5bb9aeb2 | 1051 | |
2569938d VZ |
1052 | \membersection{wxFileName::operator==}\label{wxfilenameoperatorequal} |
1053 | ||
2b5f62a0 | 1054 | \constfunc{bool operator}{operator==}{\param{const wxFileName\& }{filename}} |
2569938d | 1055 | |
2b5f62a0 | 1056 | \constfunc{bool operator}{operator==}{\param{const wxString\& }{filename}} |
2569938d | 1057 | |
0894707e | 1058 | Returns {\tt true} if the filenames are equal. The string {\it filenames} is |
2b5f62a0 VZ |
1059 | interpreted as a path in the native filename format. |
1060 | ||
5bb9aeb2 | 1061 | |
2b5f62a0 VZ |
1062 | \membersection{wxFileName::operator!=}\label{wxfilenameoperatornotequal} |
1063 | ||
1064 | \constfunc{bool operator}{operator!=}{\param{const wxFileName\& }{filename}} | |
1065 | ||
1066 | \constfunc{bool operator}{operator!=}{\param{const wxString\& }{filename}} | |
1067 | ||
0894707e | 1068 | Returns {\tt true} if the filenames are different. The string {\it filenames} |
2b5f62a0 | 1069 | is interpreted as a path in the native filename format. |
6f91bc33 | 1070 |