]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
55034339 | 2 | // Name: wx/filefn.h |
c801d85f KB |
3 | // Purpose: File- and directory-related functions |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 29/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _FILEFN_H_ |
13 | #define _FILEFN_H_ | |
c801d85f | 14 | |
ed58dbea | 15 | #include "wx/list.h" |
b76069e2 | 16 | #include "wx/arrstr.h" |
e49f47aa | 17 | |
6294ac2e VZ |
18 | #ifdef __WXWINCE__ |
19 | #include "wx/msw/wince/time.h" | |
20 | #include "wx/msw/private.h" | |
21 | #else | |
22 | #include <time.h> | |
0e0126c2 | 23 | #endif |
a47ce4a7 | 24 | |
6294ac2e VZ |
25 | #ifdef __WXWINCE__ |
26 | // Nothing | |
27 | #elif !defined(__MWERKS__) | |
28 | #include <sys/types.h> | |
29 | #include <sys/stat.h> | |
30 | #else | |
31 | #ifdef __MACH__ | |
32 | #include <sys/types.h> | |
33 | #include <utime.h> | |
34 | #include <sys/stat.h> | |
35 | #include <unistd.h> | |
36 | #else | |
37 | #include <stat.h> | |
38 | #include <unistd.h> | |
39 | #include <unix.h> | |
40 | #endif | |
41 | #endif | |
42 | ||
43 | #ifdef __OS2__ | |
44 | // need to check for __OS2__ first since currently both | |
45 | // __OS2__ and __UNIX__ are defined. | |
46 | #include <process.h> | |
47 | #include "wx/os2/private.h" | |
0872eaf9 WS |
48 | #ifdef __WATCOMC__ |
49 | #include <direct.h> | |
50 | #endif | |
6294ac2e VZ |
51 | #include <io.h> |
52 | #ifdef __EMX__ | |
53 | #include <unistd.h> | |
54 | #endif | |
55 | #elif defined(__UNIX__) | |
56 | #include <unistd.h> | |
57 | #include <dirent.h> | |
58 | #endif | |
59 | ||
60 | #if defined(__WINDOWS__) && !defined(__WXMICROWIN__) | |
f172cb82 | 61 | #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__WXWINCE__) && !defined(__CYGWIN__) |
6294ac2e VZ |
62 | #include <direct.h> |
63 | #include <dos.h> | |
64 | #include <io.h> | |
65 | #endif // __WINDOWS__ | |
66 | #endif // native Win compiler | |
67 | ||
68 | #if defined(__DOS__) | |
69 | #ifdef __WATCOMC__ | |
70 | #include <direct.h> | |
71 | #include <dos.h> | |
72 | #include <io.h> | |
73 | #endif | |
74 | #ifdef __DJGPP__ | |
75 | #include <io.h> | |
76 | #include <unistd.h> | |
77 | #endif | |
78 | #endif | |
79 | ||
80 | #ifdef __BORLANDC__ // Please someone tell me which version of Borland needs | |
81 | // this (3.1 I believe) and how to test for it. | |
82 | // If this works for Borland 4.0 as well, then no worries. | |
83 | #include <dir.h> | |
84 | #endif | |
85 | ||
6294ac2e VZ |
86 | #ifndef __WXWINCE__ |
87 | #include <fcntl.h> // O_RDONLY &c | |
88 | #endif | |
bd362275 | 89 | |
45ea509a VZ |
90 | // ---------------------------------------------------------------------------- |
91 | // constants | |
92 | // ---------------------------------------------------------------------------- | |
c801d85f | 93 | |
52de37c7 VS |
94 | #if defined(__VISUALC__) || defined(__DIGITALMARS__) |
95 | typedef int mode_t; | |
96 | #endif | |
97 | ||
0e0126c2 RR |
98 | #ifdef __WXWINCE__ |
99 | typedef long off_t; | |
100 | #else | |
6294ac2e VZ |
101 | // define off_t |
102 | #if !defined(__WXMAC__) || defined(__UNIX__) || defined(__MACH__) | |
103 | #include <sys/types.h> | |
104 | #else | |
105 | typedef long off_t; | |
106 | #endif | |
17dff81c | 107 | #endif |
45ea509a | 108 | |
65df77ec | 109 | #if (defined(__VISUALC__) && !defined(__WXWINCE__)) || ( defined(__MWERKS__) && defined( __INTEL__) ) |
3f4a0c5b | 110 | typedef _off_t off_t; |
2bdf7154 | 111 | #elif defined(__SYMANTEC__) |
3f4a0c5b | 112 | typedef long off_t; |
2d2ed20f | 113 | #elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__) |
8be97d65 | 114 | typedef long off_t; |
2432b92d JS |
115 | #endif |
116 | ||
7af89395 VZ |
117 | enum wxSeekMode |
118 | { | |
45ea509a VZ |
119 | wxFromStart, |
120 | wxFromCurrent, | |
121 | wxFromEnd | |
7af89395 | 122 | }; |
45ea509a | 123 | |
0912690b | 124 | enum wxFileKind |
3c70014d | 125 | { |
0912690b MW |
126 | wxFILE_KIND_UNKNOWN, |
127 | wxFILE_KIND_DISK, // a file supporting seeking to arbitrary offsets | |
128 | wxFILE_KIND_TERMINAL, // a tty | |
129 | wxFILE_KIND_PIPE // a pipe | |
3c70014d MW |
130 | }; |
131 | ||
9508a23a VZ |
132 | // we redefine these constants here because S_IREAD &c are _not_ standard |
133 | // however, we do assume that the values correspond to the Unix umask bits | |
134 | enum wxPosixPermissions | |
135 | { | |
136 | // standard Posix names for these permission flags: | |
137 | wxS_IRUSR = 00400, | |
138 | wxS_IWUSR = 00200, | |
139 | wxS_IXUSR = 00100, | |
140 | ||
141 | wxS_IRGRP = 00040, | |
142 | wxS_IWGRP = 00020, | |
143 | wxS_IXGRP = 00010, | |
144 | ||
145 | wxS_IROTH = 00004, | |
146 | wxS_IWOTH = 00002, | |
147 | wxS_IXOTH = 00001, | |
148 | ||
149 | // longer but more readable synonyms for the constants above: | |
150 | wxPOSIX_USER_READ = wxS_IRUSR, | |
151 | wxPOSIX_USER_WRITE = wxS_IWUSR, | |
152 | wxPOSIX_USER_EXECUTE = wxS_IXUSR, | |
153 | ||
154 | wxPOSIX_GROUP_READ = wxS_IRGRP, | |
155 | wxPOSIX_GROUP_WRITE = wxS_IWGRP, | |
156 | wxPOSIX_GROUP_EXECUTE = wxS_IXGRP, | |
157 | ||
158 | wxPOSIX_OTHERS_READ = wxS_IROTH, | |
159 | wxPOSIX_OTHERS_WRITE = wxS_IWOTH, | |
160 | wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH, | |
161 | ||
162 | // default mode for the new files: allow reading/writing them to everybody but | |
163 | // the effective file mode will be set after anding this value with umask and | |
164 | // so won't include wxS_IW{GRP,OTH} for the default 022 umask value | |
165 | wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \ | |
166 | wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \ | |
167 | wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE), | |
168 | ||
169 | // default mode for the new directories (see wxFileName::Mkdir): allow | |
170 | // reading/writing/executing them to everybody, but just like wxS_DEFAULT | |
171 | // the effective directory mode will be set after anding this value with umask | |
172 | wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \ | |
173 | wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \ | |
174 | wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE) | |
175 | }; | |
176 | ||
f6bcfd97 BP |
177 | // ---------------------------------------------------------------------------- |
178 | // declare our versions of low level file functions: some compilers prepend | |
179 | // underscores to the usual names, some also have Unicode versions of them | |
180 | // ---------------------------------------------------------------------------- | |
181 | ||
6294ac2e VZ |
182 | // Wrappers around Win32 api functions like CreateFile, ReadFile and such |
183 | // Implemented in filefnwce.cpp | |
08c63240 | 184 | #if defined( __WXWINCE__) |
6294ac2e | 185 | typedef __int64 wxFileOffset; |
16c15822 | 186 | #define wxFileOffsetFmtSpec wxT("I64") |
52de37c7 VS |
187 | WXDLLIMPEXP_BASE int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode)); |
188 | WXDLLIMPEXP_BASE int wxCRT_Access(const wxChar *name, int WXUNUSED(how)); | |
aec1621e VS |
189 | WXDLLIMPEXP_BASE int wxClose(int fd); |
190 | WXDLLIMPEXP_BASE int wxFsync(int WXUNUSED(fd)); | |
191 | WXDLLIMPEXP_BASE int wxRead(int fd, void *buf, unsigned int count); | |
192 | WXDLLIMPEXP_BASE int wxWrite(int fd, const void *buf, unsigned int count); | |
193 | WXDLLIMPEXP_BASE int wxEof(int fd); | |
194 | WXDLLIMPEXP_BASE wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin); | |
6294ac2e | 195 | #define wxLSeek wxSeek |
aec1621e | 196 | WXDLLIMPEXP_BASE wxFileOffset wxTell(int fd); |
27b2dd53 | 197 | |
c34db1be | 198 | // always Unicode under WinCE |
52de37c7 VS |
199 | #define wxCRT_MkDir _wmkdir |
200 | #define wxCRT_RmDir _wrmdir | |
201 | #define wxCRT_Stat _wstat | |
6294ac2e | 202 | #define wxStructStat struct _stat |
d98a58c5 | 203 | #elif (defined(__WINDOWS__) || defined(__OS2__)) && \ |
dedcebb9 VZ |
204 | ( \ |
205 | defined(__VISUALC__) || \ | |
98225d02 | 206 | defined(__MINGW64__) || \ |
dedcebb9 VZ |
207 | (defined(__MINGW32__) && !defined(__WINE__) && \ |
208 | wxCHECK_W32API_VERSION(0, 5)) || \ | |
209 | defined(__MWERKS__) || \ | |
210 | defined(__DMC__) || \ | |
211 | defined(__WATCOMC__) || \ | |
212 | defined(__BORLANDC__) \ | |
213 | ) | |
4004775e | 214 | |
224d978f | 215 | // temporary defines just used immediately below |
4ae9be50 | 216 | #undef wxHAS_HUGE_FILES |
224d978f | 217 | #undef wxHAS_HUGE_STDIO_FILES |
dedcebb9 | 218 | |
76c36512 VZ |
219 | // detect compilers which have support for huge files |
220 | #if defined(__VISUALC__) | |
c26d982b | 221 | #define wxHAS_HUGE_FILES 1 |
98225d02 | 222 | #elif defined(__MINGW32__) || defined(__MINGW64__) |
4ae9be50 | 223 | #define wxHAS_HUGE_FILES 1 |
1ad688c9 VZ |
224 | #elif defined(_LARGE_FILES) |
225 | #define wxHAS_HUGE_FILES 1 | |
6294ac2e VZ |
226 | #endif |
227 | ||
224d978f MW |
228 | // detect compilers which have support for huge stdio files |
229 | #if wxCHECK_VISUALC_VERSION(8) | |
230 | #define wxHAS_HUGE_STDIO_FILES | |
231 | #define wxFseek _fseeki64 | |
232 | #define wxFtell _ftelli64 | |
61a69259 MW |
233 | #elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc) |
234 | #define wxHAS_HUGE_STDIO_FILES | |
235 | #define wxFseek fseeko64 | |
236 | #define wxFtell ftello64 | |
224d978f MW |
237 | #endif |
238 | ||
1ad688c9 VZ |
239 | // other Windows compilers (DMC, Watcom, Metrowerks and Borland) don't have |
240 | // huge file support (or at least not all functions needed for it by wx) | |
241 | // currently | |
242 | ||
4bf3e3a7 VZ |
243 | // types |
244 | ||
1ad688c9 | 245 | #ifdef wxHAS_HUGE_FILES |
6294ac2e VZ |
246 | typedef wxLongLong_t wxFileOffset; |
247 | #define wxFileOffsetFmtSpec wxLongLongFmtSpec | |
248 | #else | |
4004775e | 249 | typedef off_t wxFileOffset; |
6294ac2e VZ |
250 | #endif |
251 | ||
4bf3e3a7 VZ |
252 | // at least Borland 5.5 doesn't like "struct ::stat" so don't use the scope |
253 | // resolution operator present in wxPOSIX_IDENT for it | |
254 | #ifdef __BORLANDC__ | |
255 | #define wxPOSIX_STRUCT(s) struct s | |
256 | #else | |
257 | #define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s) | |
258 | #endif | |
259 | ||
260 | // Notice that Watcom is the only compiler to have a wide char | |
261 | // version of struct stat as well as a wide char stat function variant. | |
262 | // This was dropped since OW 1.4 "for consistency across platforms". | |
263 | // | |
264 | // Borland is also special in that it uses _stat with Unicode functions | |
265 | // (for MSVC compatibility?) but stat with ANSI ones | |
266 | #ifdef __BORLANDC__ | |
267 | #if wxHAS_HUGE_FILES | |
268 | #define wxStructStat struct stati64 | |
269 | #else | |
270 | #if wxUSE_UNICODE | |
271 | #define wxStructStat struct _stat | |
272 | #else | |
273 | #define wxStructStat struct stat | |
274 | #endif | |
275 | #endif | |
276 | #else // !__BORLANDC__ | |
277 | #ifdef wxHAS_HUGE_FILES | |
278 | #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) | |
279 | #define wxStructStat struct _wstati64 | |
280 | #else | |
281 | #define wxStructStat struct _stati64 | |
282 | #endif | |
283 | #else | |
284 | #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4) | |
285 | #define wxStructStat struct _wstat | |
286 | #else | |
287 | #define wxStructStat struct _stat | |
288 | #endif | |
289 | #endif | |
290 | #endif // __BORLANDC__/!__BORLANDC__ | |
291 | ||
f49ad976 VZ |
292 | |
293 | // functions | |
294 | ||
295 | // MSVC and compatible compilers prepend underscores to the POSIX function | |
296 | // names, other compilers don't and even if their later versions usually do | |
297 | // define the versions with underscores for MSVC compatibility, it's better | |
298 | // to avoid using them as they're not present in earlier versions and | |
299 | // always using the native functions spelling is easier than testing for | |
300 | // the versions | |
3656eefc | 301 | #if defined(__BORLANDC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__MINGW64__) |
f49ad976 VZ |
302 | #define wxPOSIX_IDENT(func) ::func |
303 | #else // by default assume MSVC-compatible names | |
304 | #define wxPOSIX_IDENT(func) _ ## func | |
305 | #define wxHAS_UNDERSCORES_IN_POSIX_IDENTS | |
306 | #endif | |
307 | ||
f49ad976 VZ |
308 | // first functions not working with strings, i.e. without ANSI/Unicode |
309 | // complications | |
310 | #define wxClose wxPOSIX_IDENT(close) | |
6294ac2e VZ |
311 | |
312 | #if defined(__MWERKS__) | |
313 | #if __MSL__ >= 0x6000 | |
6d067eb6 VZ |
314 | #define wxRead(fd, buf, nCount) _read(fd, (void *)buf, nCount) |
315 | #define wxWrite(fd, buf, nCount) _write(fd, (void *)buf, nCount) | |
6294ac2e | 316 | #else |
6d067eb6 VZ |
317 | #define wxRead(fd, buf, nCount)\ |
318 | _read(fd, (const char *)buf, nCount) | |
319 | #define wxWrite(fd, buf, nCount)\ | |
320 | _write(fd, (const char *)buf, nCount) | |
6294ac2e | 321 | #endif |
f49ad976 VZ |
322 | #else // __MWERKS__ |
323 | #define wxRead wxPOSIX_IDENT(read) | |
324 | #define wxWrite wxPOSIX_IDENT(write) | |
6294ac2e | 325 | #endif |
f49ad976 | 326 | |
1ad688c9 | 327 | #ifdef wxHAS_HUGE_FILES |
3656eefc SN |
328 | #ifndef __MINGW64__ |
329 | #define wxSeek wxPOSIX_IDENT(lseeki64) | |
330 | #define wxLseek wxPOSIX_IDENT(lseeki64) | |
331 | #define wxTell wxPOSIX_IDENT(telli64) | |
332 | #else | |
333 | // unfortunately, mingw-W64 is somewhat inconsistent... | |
334 | #define wxSeek _lseeki64 | |
335 | #define wxLseek _lseeki64 | |
336 | #define wxTell _telli64 | |
337 | #endif | |
dedcebb9 | 338 | #else // !wxHAS_HUGE_FILES |
f49ad976 VZ |
339 | #define wxSeek wxPOSIX_IDENT(lseek) |
340 | #define wxLseek wxPOSIX_IDENT(lseek) | |
341 | #define wxTell wxPOSIX_IDENT(tell) | |
dedcebb9 VZ |
342 | #endif // wxHAS_HUGE_FILES/!wxHAS_HUGE_FILES |
343 | ||
f49ad976 | 344 | #ifndef __WATCOMC__ |
1b96afaa VZ |
345 | #if !defined(__BORLANDC__) || (__BORLANDC__ > 0x540) |
346 | // NB: this one is not POSIX and always has the underscore | |
347 | #define wxFsync _commit | |
dedcebb9 | 348 | |
1b96afaa VZ |
349 | // could be already defined by configure (Cygwin) |
350 | #ifndef HAVE_FSYNC | |
351 | #define HAVE_FSYNC | |
352 | #endif | |
353 | #endif // BORLANDC | |
1239ac2e | 354 | #endif |
f6bcfd97 | 355 | |
f49ad976 VZ |
356 | #define wxEof wxPOSIX_IDENT(eof) |
357 | ||
358 | // then the functions taking strings | |
d5e71e81 VZ |
359 | |
360 | // first the ANSI versions | |
361 | #define wxCRT_OpenA wxPOSIX_IDENT(open) | |
362 | #define wxCRT_AccessA wxPOSIX_IDENT(access) | |
363 | #define wxCRT_MkDirA wxPOSIX_IDENT(mkdir) | |
364 | #define wxCRT_RmDirA wxPOSIX_IDENT(rmdir) | |
365 | #ifdef wxHAS_HUGE_FILES | |
e33cedf4 VZ |
366 | // MinGW-64 provides underscore-less versions of all file functions |
367 | // except for this one. | |
368 | #ifdef __MINGW64__ | |
369 | #define wxCRT_StatA _stati64 | |
370 | #else | |
371 | #define wxCRT_StatA wxPOSIX_IDENT(stati64) | |
372 | #endif | |
d5e71e81 VZ |
373 | #else |
374 | // Unfortunately Watcom is not consistent | |
375 | #if defined(__OS2__) && defined(__WATCOMC__) | |
376 | #define wxCRT_StatA _stat | |
377 | #else | |
378 | #define wxCRT_StatA wxPOSIX_IDENT(stat) | |
379 | #endif | |
380 | #endif | |
381 | ||
382 | // then wide char ones | |
383 | #if wxUSE_UNICODE | |
384 | // special workaround for buggy wopen() in bcc 5.5 | |
385 | #if defined(__BORLANDC__) && \ | |
386 | (__BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551) | |
387 | WXDLLIMPEXP_BASE int wxCRT_OpenW(const wxChar *pathname, | |
388 | int flags, mode_t mode); | |
389 | #else | |
390 | #define wxCRT_OpenW _wopen | |
391 | #endif | |
392 | ||
393 | #define wxCRT_AccessW _waccess | |
394 | #define wxCRT_MkDirW _wmkdir | |
395 | #define wxCRT_RmDirW _wrmdir | |
396 | #ifdef wxHAS_HUGE_FILES | |
397 | #define wxCRT_StatW _wstati64 | |
398 | #else | |
399 | #define wxCRT_StatW _wstat | |
400 | #endif | |
401 | #endif // wxUSE_UNICODE | |
402 | ||
403 | ||
404 | // finally the default char-type versions | |
f6bcfd97 | 405 | #if wxUSE_UNICODE |
f030eeed | 406 | #if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__) |
6dad7fff | 407 | // implement the missing file functions in Win9x ourselves |
d5e71e81 VZ |
408 | WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, |
409 | int flags, int mode); | |
410 | WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name, | |
411 | int mode); | |
412 | WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name); | |
413 | WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name); | |
414 | ||
415 | WXDLLIMPEXP_BASE int | |
416 | wxMSLU__wstat(const wxChar *name, wxStructStat *buffer); | |
4876ba0b | 417 | |
52de37c7 | 418 | #define wxCRT_Open wxMSLU__wopen |
a62848fd | 419 | |
52de37c7 VS |
420 | #define wxCRT_Access wxMSLU__waccess |
421 | #define wxCRT_MkDir wxMSLU__wmkdir | |
422 | #define wxCRT_RmDir wxMSLU__wrmdir | |
d5e71e81 | 423 | #define wxCRT_Stat wxMSLU__wstat |
f49ad976 | 424 | #else // !wxUSE_UNICODE_MSLU |
d5e71e81 VZ |
425 | #define wxCRT_Open wxCRT_OpenW |
426 | #define wxCRT_Access wxCRT_AccessW | |
427 | #define wxCRT_MkDir wxCRT_MkDirW | |
428 | #define wxCRT_RmDir wxCRT_RmDirW | |
429 | #define wxCRT_Stat wxCRT_StatW | |
f49ad976 | 430 | #endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU |
f6bcfd97 | 431 | #else // !wxUSE_UNICODE |
d5e71e81 VZ |
432 | #define wxCRT_Open wxCRT_OpenA |
433 | #define wxCRT_Access wxCRT_AccessA | |
434 | #define wxCRT_MkDir wxCRT_MkDirA | |
435 | #define wxCRT_RmDir wxCRT_RmDirA | |
436 | #define wxCRT_Stat wxCRT_StatA | |
dedcebb9 | 437 | #endif // wxUSE_UNICODE/!wxUSE_UNICODE |
f6bcfd97 | 438 | |
d5e71e81 | 439 | |
f6bcfd97 | 440 | // constants (unless already defined by the user code) |
f49ad976 | 441 | #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS |
eb84314b VZ |
442 | #ifndef O_RDONLY |
443 | #define O_RDONLY _O_RDONLY | |
444 | #define O_WRONLY _O_WRONLY | |
445 | #define O_RDWR _O_RDWR | |
446 | #define O_EXCL _O_EXCL | |
447 | #define O_CREAT _O_CREAT | |
448 | #define O_BINARY _O_BINARY | |
449 | #endif | |
450 | ||
451 | #ifndef S_IFMT | |
452 | #define S_IFMT _S_IFMT | |
453 | #define S_IFDIR _S_IFDIR | |
454 | #define S_IFREG _S_IFREG | |
455 | #endif | |
f49ad976 | 456 | #endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS |
6294ac2e | 457 | |
1ad688c9 | 458 | #ifdef wxHAS_HUGE_FILES |
224d978f | 459 | // wxFile is present and supports large files. |
3d3c6c45 | 460 | #if wxUSE_FILE |
82b99cf9 | 461 | #define wxHAS_LARGE_FILES |
3d3c6c45 | 462 | #endif |
224d978f MW |
463 | // wxFFile is present and supports large files |
464 | #if wxUSE_FFILE && defined wxHAS_HUGE_STDIO_FILES | |
465 | #define wxHAS_LARGE_FFILES | |
466 | #endif | |
3d3c6c45 | 467 | #endif |
dedcebb9 | 468 | |
224d978f | 469 | // private defines, undefine so that nobody gets tempted to use |
4ae9be50 | 470 | #undef wxHAS_HUGE_FILES |
224d978f | 471 | #undef wxHAS_HUGE_STDIO_FILES |
dedcebb9 | 472 | #else // Unix or Windows using unknown compiler, assume POSIX supported |
6294ac2e | 473 | typedef off_t wxFileOffset; |
68fe70ea | 474 | #ifdef HAVE_LARGEFILE_SUPPORT |
6294ac2e | 475 | #define wxFileOffsetFmtSpec wxLongLongFmtSpec |
bd3cea7d VZ |
476 | wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t), |
477 | BadFileSizeType ); | |
3d3c6c45 | 478 | // wxFile is present and supports large files |
68fe70ea | 479 | #if wxUSE_FILE |
82b99cf9 | 480 | #define wxHAS_LARGE_FILES |
3d3c6c45 MW |
481 | #endif |
482 | // wxFFile is present and supports large files | |
68fe70ea | 483 | #if wxUSE_FFILE && (SIZEOF_LONG == 8 || defined HAVE_FSEEKO) |
82b99cf9 | 484 | #define wxHAS_LARGE_FFILES |
3d3c6c45 | 485 | #endif |
224d978f MW |
486 | #ifdef HAVE_FSEEKO |
487 | #define wxFseek fseeko | |
488 | #define wxFtell ftello | |
489 | #endif | |
6294ac2e | 490 | #else |
9a83f860 | 491 | #define wxFileOffsetFmtSpec wxT("") |
6294ac2e | 492 | #endif |
f6bcfd97 | 493 | // functions |
f6bcfd97 | 494 | #define wxClose close |
6294ac2e VZ |
495 | #define wxRead ::read |
496 | #define wxWrite ::write | |
f6bcfd97 | 497 | #define wxLseek lseek |
6294ac2e | 498 | #define wxSeek lseek |
52ca5b59 | 499 | #define wxFsync fsync |
f6bcfd97 BP |
500 | #define wxEof eof |
501 | ||
52de37c7 VS |
502 | #define wxCRT_MkDir mkdir |
503 | #define wxCRT_RmDir rmdir | |
f6bcfd97 BP |
504 | |
505 | #define wxTell(fd) lseek(fd, 0, SEEK_CUR) | |
506 | ||
f6bcfd97 | 507 | #define wxStructStat struct stat |
a62848fd | 508 | |
52de37c7 VS |
509 | #define wxCRT_Open open |
510 | #define wxCRT_Stat stat | |
511 | #define wxCRT_Lstat lstat | |
512 | #define wxCRT_Access access | |
194b2267 | 513 | |
dedcebb9 | 514 | #define wxHAS_NATIVE_LSTAT |
06e66bd0 | 515 | #endif // platforms |
f6bcfd97 | 516 | |
52de37c7 VS |
517 | // if the platform doesn't have symlinks, define wxCRT_Lstat to be the same as |
518 | // wxCRT_Stat to avoid #ifdefs in the code using it | |
519 | #ifndef wxHAS_NATIVE_LSTAT | |
520 | #define wxCRT_Lstat wxCRT_Stat | |
521 | #endif | |
522 | ||
224d978f MW |
523 | // define wxFseek/wxFtell to large file versions if available (done above) or |
524 | // to fseek/ftell if not, to save ifdefs in using code | |
525 | #ifndef wxFseek | |
526 | #define wxFseek fseek | |
527 | #endif | |
528 | #ifndef wxFtell | |
529 | #define wxFtell ftell | |
530 | #endif | |
531 | ||
52de37c7 VS |
532 | inline int wxAccess(const wxString& path, mode_t mode) |
533 | { return wxCRT_Access(path.fn_str(), mode); } | |
534 | inline int wxOpen(const wxString& path, int flags, mode_t mode) | |
535 | { return wxCRT_Open(path.fn_str(), flags, mode); } | |
d6f2a891 VZ |
536 | |
537 | // FIXME-CE: provide our own implementations of the missing CRT functions | |
538 | #ifndef __WXWINCE__ | |
539 | inline int wxStat(const wxString& path, wxStructStat *buf) | |
540 | { return wxCRT_Stat(path.fn_str(), buf); } | |
541 | inline int wxLstat(const wxString& path, wxStructStat *buf) | |
542 | { return wxCRT_Lstat(path.fn_str(), buf); } | |
52de37c7 VS |
543 | inline int wxRmDir(const wxString& path) |
544 | { return wxCRT_RmDir(path.fn_str()); } | |
715e4f7e VZ |
545 | #if (defined(__WINDOWS__) && !defined(__CYGWIN__)) \ |
546 | || (defined(__OS2__) && defined(__WATCOMC__)) | |
52de37c7 VS |
547 | inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0) |
548 | { return wxCRT_MkDir(path.fn_str()); } | |
549 | #else | |
550 | inline int wxMkDir(const wxString& path, mode_t mode) | |
551 | { return wxCRT_MkDir(path.fn_str(), mode); } | |
552 | #endif | |
d6f2a891 | 553 | #endif // !__WXWINCE__ |
52de37c7 | 554 | |
3d3c6c45 MW |
555 | #ifdef O_BINARY |
556 | #define wxO_BINARY O_BINARY | |
557 | #else | |
558 | #define wxO_BINARY 0 | |
559 | #endif | |
560 | ||
06e66bd0 VZ |
561 | #if defined(__VISAGECPP__) && __IBMCPP__ >= 400 |
562 | // | |
563 | // VisualAge C++ V4.0 cannot have any external linkage const decs | |
564 | // in headers included by more than one primary source | |
565 | // | |
30984dea | 566 | extern const int wxInvalidOffset; |
06e66bd0 | 567 | #else |
30984dea | 568 | const int wxInvalidOffset = -1; |
06e66bd0 | 569 | #endif |
f6bcfd97 | 570 | |
45ea509a VZ |
571 | // ---------------------------------------------------------------------------- |
572 | // functions | |
573 | // ---------------------------------------------------------------------------- | |
bddd7a8d | 574 | WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename); |
c801d85f KB |
575 | |
576 | // does the path exist? (may have or not '/' or '\\' at the end) | |
e960c20e | 577 | WXDLLIMPEXP_BASE bool wxDirExists(const wxString& pathName); |
c801d85f | 578 | |
bddd7a8d | 579 | WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename); |
c801d85f KB |
580 | |
581 | // Get filename | |
bddd7a8d VZ |
582 | WXDLLIMPEXP_BASE wxChar* wxFileNameFromPath(wxChar *path); |
583 | WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path); | |
c801d85f KB |
584 | |
585 | // Get directory | |
bddd7a8d | 586 | WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path); |
c801d85f | 587 | |
47d281e6 FM |
588 | // all deprecated functions below are deprecated in favour of wxFileName's methods |
589 | #if WXWIN_COMPATIBILITY_2_8 | |
c801d85f | 590 | |
47d281e6 FM |
591 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(char *s) ); |
592 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(wchar_t *s) ); | |
593 | ||
220ea2b9 VZ |
594 | wxDEPRECATED_BUT_USED_INTERNALLY( |
595 | WXDLLIMPEXP_BASE void wxUnix2DosFilename(char *s) ); | |
596 | wxDEPRECATED_BUT_USED_INTERNALLY( | |
597 | WXDLLIMPEXP_BASE void wxUnix2DosFilename(wchar_t *s) ); | |
c801d85f KB |
598 | |
599 | // Strip the extension, in situ | |
181dd701 VZ |
600 | // Deprecated in favour of wxFileName::StripExtension() but notice that their |
601 | // behaviour is slightly different, see the manual | |
47d281e6 FM |
602 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(char *buffer) ); |
603 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wchar_t *buffer) ); | |
604 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer) ); | |
c801d85f | 605 | |
ade35f11 | 606 | // Get a temporary filename |
d3b9f782 | 607 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = NULL) ); |
48598c66 | 608 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf) ); |
c801d85f KB |
609 | |
610 | // Expand file name (~/ and ${OPENWINHOME}/ stuff) | |
48598c66 FM |
611 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxExpandPath(char *dest, const wxString& path) ); |
612 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxExpandPath(wchar_t *dest, const wxString& path) ); | |
47d281e6 | 613 | // DEPRECATED: use wxFileName::Normalize(wxPATH_NORM_ENV_VARS) |
c801d85f KB |
614 | |
615 | // Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib) | |
616 | // and make (if under the home tree) relative to home | |
617 | // [caller must copy-- volatile] | |
47d281e6 | 618 | wxDEPRECATED( |
bddd7a8d | 619 | WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename, |
ade35f11 | 620 | const wxString& envname = wxEmptyString, |
47d281e6 FM |
621 | const wxString& user = wxEmptyString) ); |
622 | // DEPRECATED: use wxFileName::ReplaceEnvVariable and wxFileName::ReplaceHomeDir | |
c801d85f KB |
623 | |
624 | // Destructive removal of /./ and /../ stuff | |
48598c66 FM |
625 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxRealPath(char *path) ); |
626 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxRealPath(wchar_t *path) ); | |
627 | wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path) ); | |
47d281e6 | 628 | // DEPRECATED: use wxFileName::Normalize instead |
c801d85f KB |
629 | |
630 | // Allocate a copy of the full absolute path | |
47d281e6 FM |
631 | wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path) ); |
632 | // DEPRECATED: use wxFileName::MakeAbsolute instead | |
633 | #endif | |
c801d85f KB |
634 | |
635 | // Get first file name matching given wild card. | |
636 | // Flags are reserved for future use. | |
637 | #define wxFILE 1 | |
638 | #define wxDIR 2 | |
52de37c7 | 639 | WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxString& spec, int flags = wxFILE); |
bddd7a8d | 640 | WXDLLIMPEXP_BASE wxString wxFindNextFile(); |
c801d85f KB |
641 | |
642 | // Does the pattern contain wildcards? | |
bddd7a8d | 643 | WXDLLIMPEXP_BASE bool wxIsWild(const wxString& pattern); |
c801d85f KB |
644 | |
645 | // Does the pattern match the text (usually a filename)? | |
a62848fd | 646 | // If dot_special is true, doesn't match * against . (eliminating |
c801d85f | 647 | // `hidden' dot files) |
a62848fd | 648 | WXDLLIMPEXP_BASE bool wxMatchWild(const wxString& pattern, const wxString& text, bool dot_special = true); |
c801d85f KB |
649 | |
650 | // Concatenate two files to form third | |
bddd7a8d | 651 | WXDLLIMPEXP_BASE bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3); |
c801d85f KB |
652 | |
653 | // Copy file1 to file2 | |
bddd7a8d | 654 | WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& file1, const wxString& file2, |
a62848fd | 655 | bool overwrite = true); |
c801d85f KB |
656 | |
657 | // Remove file | |
bddd7a8d | 658 | WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file); |
c801d85f KB |
659 | |
660 | // Rename file | |
57e988b8 | 661 | WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite = true); |
c801d85f KB |
662 | |
663 | // Get current working directory. | |
2587df2c VS |
664 | #if WXWIN_COMPATIBILITY_2_6 |
665 | // If buf is NULL, allocates space using new, else | |
666 | // copies into buf. | |
667 | // IMPORTANT NOTE getcwd is know not to work under some releases | |
668 | // of Win32s 1.3, according to MS release notes! | |
d3b9f782 | 669 | wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = NULL, int sz = 1000) ); |
2587df2c VS |
670 | // new and preferred version of wxGetWorkingDirectory |
671 | // NB: can't have the same name because of overloading ambiguity | |
672 | #endif // WXWIN_COMPATIBILITY_2_6 | |
bddd7a8d | 673 | WXDLLIMPEXP_BASE wxString wxGetCwd(); |
c801d85f KB |
674 | |
675 | // Set working directory | |
bddd7a8d | 676 | WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d); |
c801d85f KB |
677 | |
678 | // Make directory | |
9508a23a | 679 | WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT); |
c801d85f KB |
680 | |
681 | // Remove directory. Flags reserved for future use. | |
bddd7a8d | 682 | WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0); |
c801d85f | 683 | |
3c70014d | 684 | // Return the type of an open file |
0912690b | 685 | WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd); |
9802983f | 686 | WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp); |
3c70014d | 687 | |
2587df2c VS |
688 | #if WXWIN_COMPATIBILITY_2_6 |
689 | // compatibility defines, don't use in new code | |
690 | wxDEPRECATED( inline bool wxPathExists(const wxChar *pszPathName) ); | |
691 | inline bool wxPathExists(const wxChar *pszPathName) | |
692 | { | |
693 | return wxDirExists(pszPathName); | |
694 | } | |
695 | #endif //WXWIN_COMPATIBILITY_2_6 | |
696 | ||
3ff07edb RR |
697 | // permissions; these functions work both on files and directories: |
698 | WXDLLIMPEXP_BASE bool wxIsWritable(const wxString &path); | |
699 | WXDLLIMPEXP_BASE bool wxIsReadable(const wxString &path); | |
700 | WXDLLIMPEXP_BASE bool wxIsExecutable(const wxString &path); | |
701 | ||
ff69a290 | 702 | // ---------------------------------------------------------------------------- |
c801d85f | 703 | // separators in file names |
ff69a290 VZ |
704 | // ---------------------------------------------------------------------------- |
705 | ||
706 | // between file name and extension | |
223d09f6 | 707 | #define wxFILE_SEP_EXT wxT('.') |
ff69a290 VZ |
708 | |
709 | // between drive/volume name and the path | |
223d09f6 | 710 | #define wxFILE_SEP_DSK wxT(':') |
ff69a290 VZ |
711 | |
712 | // between the path components | |
223d09f6 KB |
713 | #define wxFILE_SEP_PATH_DOS wxT('\\') |
714 | #define wxFILE_SEP_PATH_UNIX wxT('/') | |
844f90fb | 715 | #define wxFILE_SEP_PATH_MAC wxT(':') |
ff69a290 | 716 | #define wxFILE_SEP_PATH_VMS wxT('.') // VMS also uses '[' and ']' |
c801d85f KB |
717 | |
718 | // separator in the path list (as in PATH environment variable) | |
03e11df5 GD |
719 | // there is no PATH variable in Classic Mac OS so just use the |
720 | // semicolon (it must be different from the file name separator) | |
c801d85f | 721 | // NB: these are strings and not characters on purpose! |
223d09f6 KB |
722 | #define wxPATH_SEP_DOS wxT(";") |
723 | #define wxPATH_SEP_UNIX wxT(":") | |
03e11df5 | 724 | #define wxPATH_SEP_MAC wxT(";") |
c801d85f KB |
725 | |
726 | // platform independent versions | |
77a80672 VZ |
727 | #if defined(__UNIX__) && !defined(__OS2__) |
728 | // CYGWIN also uses UNIX settings | |
7af89395 VZ |
729 | #define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX |
730 | #define wxPATH_SEP wxPATH_SEP_UNIX | |
844f90fb | 731 | #elif defined(__MAC__) |
bedaf53e | 732 | #define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC |
3369df87 | 733 | #define wxPATH_SEP wxPATH_SEP_MAC |
1777b9bb | 734 | #else // Windows and OS/2 |
7af89395 VZ |
735 | #define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS |
736 | #define wxPATH_SEP wxPATH_SEP_DOS | |
c801d85f KB |
737 | #endif // Unix/Windows |
738 | ||
92abb45d VZ |
739 | // this is useful for wxString::IsSameAs(): to compare two file names use |
740 | // filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE) | |
28e5e577 | 741 | #if defined(__UNIX__) && !defined(__DARWIN__) && !defined(__OS2__) |
a62848fd | 742 | #define wxARE_FILENAMES_CASE_SENSITIVE true |
3369df87 | 743 | #else // Windows, Mac OS and OS/2 |
a62848fd | 744 | #define wxARE_FILENAMES_CASE_SENSITIVE false |
92abb45d VZ |
745 | #endif // Unix/Windows |
746 | ||
c801d85f | 747 | // is the char a path separator? |
9d2f3c71 | 748 | inline bool wxIsPathSeparator(wxChar c) |
903b61cc VZ |
749 | { |
750 | // under DOS/Windows we should understand both Unix and DOS file separators | |
a62848fd | 751 | #if ( defined(__UNIX__) && !defined(__OS2__) )|| defined(__MAC__) |
903b61cc VZ |
752 | return c == wxFILE_SEP_PATH; |
753 | #else | |
754 | return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX; | |
755 | #endif | |
756 | } | |
c801d85f KB |
757 | |
758 | // does the string ends with path separator? | |
52de37c7 | 759 | WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxString& filename); |
c801d85f | 760 | |
47d281e6 | 761 | #if WXWIN_COMPATIBILITY_2_8 |
92abb45d VZ |
762 | // split the full path into path (including drive for DOS), name and extension |
763 | // (understands both '/' and '\\') | |
0253bbba | 764 | // Deprecated in favour of wxFileName::SplitPath |
47d281e6 FM |
765 | wxDEPRECATED( WXDLLIMPEXP_BASE void wxSplitPath(const wxString& fileName, |
766 | wxString *pstrPath, | |
767 | wxString *pstrName, | |
768 | wxString *pstrExt) ); | |
769 | #endif | |
92abb45d | 770 | |
c801d85f | 771 | // find a file in a list of directories, returns false if not found |
52de37c7 | 772 | WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile); |
c801d85f | 773 | |
631f1bfe JS |
774 | // Get the OS directory if appropriate (such as the Windows directory). |
775 | // On non-Windows platform, probably just return the empty string. | |
bddd7a8d | 776 | WXDLLIMPEXP_BASE wxString wxGetOSDirectory(); |
631f1bfe | 777 | |
2c5e5cbd VS |
778 | #if wxUSE_DATETIME |
779 | ||
a47ce4a7 | 780 | // Get file modification time |
bddd7a8d | 781 | WXDLLIMPEXP_BASE time_t wxFileModificationTime(const wxString& filename); |
a47ce4a7 | 782 | |
2c5e5cbd VS |
783 | #endif // wxUSE_DATETIME |
784 | ||
9e152a55 WS |
785 | // Parses the wildCard, returning the number of filters. |
786 | // Returns 0 if none or if there's a problem, | |
787 | // The arrays will contain an equal number of items found before the error. | |
788 | // wildCard is in the form: | |
789 | // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png" | |
daf32463 | 790 | WXDLLIMPEXP_BASE int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters); |
9e152a55 | 791 | |
45ea509a VZ |
792 | // ---------------------------------------------------------------------------- |
793 | // classes | |
794 | // ---------------------------------------------------------------------------- | |
795 | ||
8482e4bd VZ |
796 | #ifdef __UNIX__ |
797 | ||
798 | // set umask to the given value in ctor and reset it to the old one in dtor | |
799 | class WXDLLIMPEXP_BASE wxUmaskChanger | |
800 | { | |
801 | public: | |
802 | // change the umask to the given one if it is not -1: this allows to write | |
803 | // the same code whether you really want to change umask or not, as is in | |
804 | // wxFileConfig::Flush() for example | |
805 | wxUmaskChanger(int umaskNew) | |
806 | { | |
835fab50 | 807 | m_umaskOld = umaskNew == -1 ? -1 : (int)umask((mode_t)umaskNew); |
8482e4bd VZ |
808 | } |
809 | ||
810 | ~wxUmaskChanger() | |
811 | { | |
812 | if ( m_umaskOld != -1 ) | |
813 | umask((mode_t)m_umaskOld); | |
814 | } | |
815 | ||
816 | private: | |
817 | int m_umaskOld; | |
818 | }; | |
819 | ||
820 | // this macro expands to an "anonymous" wxUmaskChanger object under Unix and | |
821 | // nothing elsewhere | |
822 | #define wxCHANGE_UMASK(m) wxUmaskChanger wxMAKE_UNIQUE_NAME(umaskChanger_)(m) | |
823 | ||
824 | #else // !__UNIX__ | |
825 | ||
826 | #define wxCHANGE_UMASK(m) | |
827 | ||
828 | #endif // __UNIX__/!__UNIX__ | |
829 | ||
830 | ||
c801d85f | 831 | // Path searching |
8daf3c36 | 832 | class WXDLLIMPEXP_BASE wxPathList : public wxArrayString |
c801d85f | 833 | { |
a6f6393c | 834 | public: |
8daf3c36 VZ |
835 | wxPathList() {} |
836 | wxPathList(const wxArrayString &arr) | |
837 | { Add(arr); } | |
838 | ||
7af89395 VZ |
839 | // Adds all paths in environment variable |
840 | void AddEnvList(const wxString& envVariable); | |
c330a2cf | 841 | |
8daf3c36 | 842 | // Adds given path to this list |
34e2d943 | 843 | bool Add(const wxString& path); |
8daf3c36 VZ |
844 | void Add(const wxArrayString &paths); |
845 | ||
7af89395 | 846 | // Find the first full path for which the file exists |
8daf3c36 VZ |
847 | wxString FindValidPath(const wxString& filename) const; |
848 | ||
7af89395 VZ |
849 | // Find the first full path for which the file exists; ensure it's an |
850 | // absolute path that gets returned. | |
8daf3c36 VZ |
851 | wxString FindAbsoluteValidPath(const wxString& filename) const; |
852 | ||
7af89395 | 853 | // Given full path and filename, add path to list |
34e2d943 | 854 | bool EnsureFileAccessible(const wxString& path); |
2587df2c VS |
855 | |
856 | #if WXWIN_COMPATIBILITY_2_6 | |
857 | // Returns true if the path is in the list | |
858 | wxDEPRECATED( bool Member(const wxString& path) const ); | |
859 | #endif | |
c801d85f KB |
860 | }; |
861 | ||
8daf3c36 | 862 | #endif // _WX_FILEFN_H_ |