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