/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/filefn.h
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/filefn.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 25962 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filefn.h
3 // Purpose: File- and directory-related functions
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id: filefn.h 53877 2008-05-31 12:43:44Z SN $
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _FILEFN_H_
13 #define _FILEFN_H_
14
15 #include "wx/list.h"
16 #include "wx/arrstr.h"
17
18 #ifdef __WXWINCE__
19 #include "wx/msw/wince/time.h"
20 #include "wx/msw/private.h"
21 #else
22 #include <time.h>
23 #endif
24
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"
48 #ifdef __WATCOMC__
49 #include <direct.h>
50 #endif
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__)
61 #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !defined(__WXWINCE__) && !defined(__CYGWIN__)
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
86 #ifdef __SALFORDC__
87 #include <dir.h>
88 #include <unix.h>
89 #endif
90
91 #ifndef __WXWINCE__
92 #include <fcntl.h> // O_RDONLY &c
93 #endif
94 // ----------------------------------------------------------------------------
95 // constants
96 // ----------------------------------------------------------------------------
97
98 #ifdef __WXWINCE__
99 typedef long off_t;
100 #else
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
107 #endif
108
109 #if (defined(__VISUALC__) && !defined(__WXWINCE__)) || ( defined(__MWERKS__) && defined( __INTEL__) )
110 typedef _off_t off_t;
111 #elif defined(__SYMANTEC__)
112 typedef long off_t;
113 #elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__)
114 typedef long off_t;
115 #endif
116
117 enum wxSeekMode
118 {
119 wxFromStart,
120 wxFromCurrent,
121 wxFromEnd
122 };
123
124 enum wxFileKind
125 {
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
130 };
131
132 // ----------------------------------------------------------------------------
133 // declare our versions of low level file functions: some compilers prepend
134 // underscores to the usual names, some also have Unicode versions of them
135 // ----------------------------------------------------------------------------
136
137 // Wrappers around Win32 api functions like CreateFile, ReadFile and such
138 // Implemented in filefnwce.cpp
139 #if defined( __WXWINCE__)
140 typedef __int64 wxFileOffset;
141 #define wxFileOffsetFmtSpec _("I64")
142 int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode));
143 int wxAccess(const wxChar *name, int WXUNUSED(how));
144 int wxClose(int fd);
145 int wxFsync(int WXUNUSED(fd));
146 int wxRead(int fd, void *buf, unsigned int count);
147 int wxWrite(int fd, const void *buf, unsigned int count);
148 int wxEof(int fd);
149 wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin);
150 #define wxLSeek wxSeek
151 wxFileOffset wxTell(int fd);
152
153 // always Unicode under WinCE
154 #define wxMkDir _wmkdir
155 #define wxRmDir _wrmdir
156 #define wxStat _wstat
157 #define wxStructStat struct _stat
158 #elif (defined(__WXMSW__) || defined(__OS2__)) && !defined(__WXPALMOS__) && \
159 ( \
160 defined(__VISUALC__) || \
161 (defined(__MINGW32__) && !defined(__WINE__) && \
162 wxCHECK_W32API_VERSION(0, 5)) || \
163 defined(__MWERKS__) || \
164 defined(__DMC__) || \
165 defined(__WATCOMC__) || \
166 defined(__BORLANDC__) \
167 )
168
169 #undef wxHAS_HUGE_FILES
170
171 // detect compilers which have support for huge files
172 #if defined(__VISUALC__)
173 #define wxHAS_HUGE_FILES 1
174 #elif defined(__MINGW32__)
175 #define wxHAS_HUGE_FILES 1
176 #elif defined(_LARGE_FILES)
177 #define wxHAS_HUGE_FILES 1
178 #endif
179
180 // other Windows compilers (DMC, Watcom, Metrowerks and Borland) don't have
181 // huge file support (or at least not all functions needed for it by wx)
182 // currently
183
184 #ifdef wxHAS_HUGE_FILES
185 typedef wxLongLong_t wxFileOffset;
186 #define wxFileOffsetFmtSpec wxLongLongFmtSpec
187 #else
188 typedef off_t wxFileOffset;
189 #endif
190
191
192 // functions
193
194 // MSVC and compatible compilers prepend underscores to the POSIX function
195 // names, other compilers don't and even if their later versions usually do
196 // define the versions with underscores for MSVC compatibility, it's better
197 // to avoid using them as they're not present in earlier versions and
198 // always using the native functions spelling is easier than testing for
199 // the versions
200 #if defined(__BORLANDC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__MINGW64__)
201 #define wxPOSIX_IDENT(func) ::func
202 #else // by default assume MSVC-compatible names
203 #define wxPOSIX_IDENT(func) _ ## func
204 #define wxHAS_UNDERSCORES_IN_POSIX_IDENTS
205 #endif
206
207 // at least Borland 5.5 doesn't like "struct ::stat" so don't use the scope
208 // resolution operator present in wxPOSIX_IDENT for it
209 #ifdef __BORLANDC__
210 #define wxPOSIX_STRUCT(s) struct s
211 #else
212 #define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s)
213 #endif
214
215 // first functions not working with strings, i.e. without ANSI/Unicode
216 // complications
217 #define wxClose wxPOSIX_IDENT(close)
218
219 #if defined(__MWERKS__)
220 #if __MSL__ >= 0x6000
221 #define wxRead(fd, buf, nCount) _read(fd, (void *)buf, nCount)
222 #define wxWrite(fd, buf, nCount) _write(fd, (void *)buf, nCount)
223 #else
224 #define wxRead(fd, buf, nCount)\
225 _read(fd, (const char *)buf, nCount)
226 #define wxWrite(fd, buf, nCount)\
227 _write(fd, (const char *)buf, nCount)
228 #endif
229 #else // __MWERKS__
230 #define wxRead wxPOSIX_IDENT(read)
231 #define wxWrite wxPOSIX_IDENT(write)
232 #endif
233
234 #ifdef wxHAS_HUGE_FILES
235 #ifndef __MINGW64__
236 #define wxSeek wxPOSIX_IDENT(lseeki64)
237 #define wxLseek wxPOSIX_IDENT(lseeki64)
238 #define wxTell wxPOSIX_IDENT(telli64)
239 #else
240 // unfortunately, mingw-W64 is somewhat inconsistent...
241 #define wxSeek _lseeki64
242 #define wxLseek _lseeki64
243 #define wxTell _telli64
244 #endif
245 #else // !wxHAS_HUGE_FILES
246 #define wxSeek wxPOSIX_IDENT(lseek)
247 #define wxLseek wxPOSIX_IDENT(lseek)
248 #define wxTell wxPOSIX_IDENT(tell)
249 #endif // wxHAS_HUGE_FILES/!wxHAS_HUGE_FILES
250
251 #ifndef __WATCOMC__
252 #if !defined(__BORLANDC__) || (__BORLANDC__ > 0x540)
253 // NB: this one is not POSIX and always has the underscore
254 #define wxFsync _commit
255
256 // could be already defined by configure (Cygwin)
257 #ifndef HAVE_FSYNC
258 #define HAVE_FSYNC
259 #endif
260 #endif // BORLANDC
261 #endif
262
263 #define wxEof wxPOSIX_IDENT(eof)
264
265 // then the functions taking strings
266 #if wxUSE_UNICODE
267 #if wxUSE_UNICODE_MSLU
268 // implement the missing file functions in Win9x ourselves
269 #if defined( __VISUALC__ ) \
270 || ( defined(__MINGW32__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
271 || ( defined(__MWERKS__) && defined(__WXMSW__) ) \
272 || ( defined(__BORLANDC__) && (__BORLANDC__ > 0x460) ) \
273 || defined(__DMC__)
274
275 WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name,
276 int flags, int mode);
277 WXDLLIMPEXP_BASE int wxMSLU__waccess(const wxChar *name,
278 int mode);
279 WXDLLIMPEXP_BASE int wxMSLU__wmkdir(const wxChar *name);
280 WXDLLIMPEXP_BASE int wxMSLU__wrmdir(const wxChar *name);
281
282 WXDLLIMPEXP_BASE int
283 wxMSLU__wstat(const wxChar *name, wxPOSIX_STRUCT(stat) *buffer);
284 WXDLLIMPEXP_BASE int
285 wxMSLU__wstati64(const wxChar *name,
286 wxPOSIX_STRUCT(stati64) *buffer);
287 #endif // Windows compilers with MSLU support
288
289 #define wxOpen wxMSLU__wopen
290
291 #define wxAccess wxMSLU__waccess
292 #define wxMkDir wxMSLU__wmkdir
293 #define wxRmDir wxMSLU__wrmdir
294 #ifdef wxHAS_HUGE_FILES
295 #define wxStat wxMSLU__wstati64
296 #else
297 #define wxStat wxMSLU__wstat
298 #endif
299 #else // !wxUSE_UNICODE_MSLU
300 #ifdef __BORLANDC__
301 #if __BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551
302 WXDLLIMPEXP_BASE int wxOpen(const wxChar *pathname,
303 int flags, mode_t mode);
304 #else
305 #define wxOpen _wopen
306 #endif
307 #define wxAccess _waccess
308 #define wxMkDir _wmkdir
309 #define wxRmDir _wrmdir
310 #ifdef wxHAS_HUGE_FILES
311 #define wxStat _wstati64
312 #else
313 #define wxStat _wstat
314 #endif
315 #else
316 #define wxOpen _wopen
317 #define wxAccess _waccess
318 #define wxMkDir _wmkdir
319 #define wxRmDir _wrmdir
320 #ifdef wxHAS_HUGE_FILES
321 #define wxStat _wstati64
322 #else
323 #define wxStat _wstat
324 #endif
325 #endif
326 #endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU
327 #else // !wxUSE_UNICODE
328 #define wxOpen wxPOSIX_IDENT(open)
329 #define wxAccess wxPOSIX_IDENT(access)
330 #define wxMkDir wxPOSIX_IDENT(mkdir)
331 #define wxRmDir wxPOSIX_IDENT(rmdir)
332 #ifdef wxHAS_HUGE_FILES
333 #define wxStat wxPOSIX_IDENT(stati64)
334 #else
335 // Unfortunately Watcom is not consistent, so:-
336 #if defined(__OS2__) && defined(__WATCOMC__)
337 #define wxStat _stat
338 #else
339 #if defined (__BORLANDC__)
340 #define wxStat _stat //wxPOSIX_IDENT(stat)
341 #else
342 #define wxStat wxPOSIX_IDENT(stat)
343 #endif // !borland
344 #endif // !watcom
345 #endif
346 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
347
348 // Types: Notice that Watcom is the only compiler to have a wide char
349 // version of struct stat as well as a wide char stat function variant.
350 // This was droped since OW 1.4 "for consistency across platforms".
351 #ifdef wxHAS_HUGE_FILES
352 #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4)
353 #define wxStructStat struct _wstati64
354 #else
355 #define wxStructStat struct _stati64
356 #endif
357 #else
358 #if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4)
359 #define wxStructStat struct _wstat
360 #else
361 #define wxStructStat struct _stat
362 #endif
363 #endif
364
365 // constants (unless already defined by the user code)
366 #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS
367 #ifndef O_RDONLY
368 #define O_RDONLY _O_RDONLY
369 #define O_WRONLY _O_WRONLY
370 #define O_RDWR _O_RDWR
371 #define O_EXCL _O_EXCL
372 #define O_CREAT _O_CREAT
373 #define O_BINARY _O_BINARY
374 #endif
375
376 #ifndef S_IFMT
377 #define S_IFMT _S_IFMT
378 #define S_IFDIR _S_IFDIR
379 #define S_IFREG _S_IFREG
380 #endif
381 #endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS
382
383 #ifdef wxHAS_HUGE_FILES
384 // wxFile is present and supports large files. Currently wxFFile
385 // doesn't have large file support with any Windows compiler (even
386 // Win64 ones).
387 #if wxUSE_FILE
388 #define wxHAS_LARGE_FILES
389 #endif
390 #endif
391
392 // it's a private define, undefine it so that nobody gets tempted to use it
393 #undef wxHAS_HUGE_FILES
394 #else // Unix or Windows using unknown compiler, assume POSIX supported
395 typedef off_t wxFileOffset;
396 #ifdef _LARGE_FILES
397 #define wxFileOffsetFmtSpec wxLongLongFmtSpec
398 wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
399 BadFileSizeType );
400 // wxFile is present and supports large files
401 #ifdef wxUSE_FILE
402 #define wxHAS_LARGE_FILES
403 #endif
404 // wxFFile is present and supports large files
405 #if SIZEOF_LONG == 8 || defined HAVE_FSEEKO
406 #define wxHAS_LARGE_FFILES
407 #endif
408 #else
409 #define wxFileOffsetFmtSpec _T("")
410 #endif
411 // functions
412 #define wxClose close
413 #define wxRead ::read
414 #define wxWrite ::write
415 #define wxLseek lseek
416 #define wxSeek lseek
417 #define wxFsync fsync
418 #define wxEof eof
419
420 #define wxMkDir mkdir
421 #define wxRmDir rmdir
422
423 #define wxTell(fd) lseek(fd, 0, SEEK_CUR)
424
425 #define wxStructStat struct stat
426
427 #if wxUSE_UNICODE
428 #define wxNEED_WX_UNISTD_H
429 #if defined(__DMC__)
430 typedef unsigned long mode_t;
431 #endif
432 WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf );
433 WXDLLIMPEXP_BASE int wxLstat( const wxChar *file_name, wxStructStat *buf );
434 WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode );
435 WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode );
436 #else
437 #define wxOpen open
438 #define wxStat stat
439 #define wxLstat lstat
440 #define wxAccess access
441 #endif
442
443 #define wxHAS_NATIVE_LSTAT
444 #endif // platforms
445
446 #ifdef O_BINARY
447 #define wxO_BINARY O_BINARY
448 #else
449 #define wxO_BINARY 0
450 #endif
451
452 // if the platform doesn't have symlinks, define wxLstat to be the same as
453 // wxStat to avoid #ifdefs in the code using it
454 #ifndef wxHAS_NATIVE_LSTAT
455 #define wxLstat wxStat
456 #endif
457
458 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
459 //
460 // VisualAge C++ V4.0 cannot have any external linkage const decs
461 // in headers included by more than one primary source
462 //
463 extern const int wxInvalidOffset;
464 #else
465 const int wxInvalidOffset = -1;
466 #endif
467
468 // ----------------------------------------------------------------------------
469 // functions
470 // ----------------------------------------------------------------------------
471 WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename);
472
473 // does the path exist? (may have or not '/' or '\\' at the end)
474 WXDLLIMPEXP_BASE bool wxDirExists(const wxChar *pszPathName);
475
476 WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename);
477
478 // Get filename
479 WXDLLIMPEXP_BASE wxChar* wxFileNameFromPath(wxChar *path);
480 WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path);
481
482 // Get directory
483 WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path);
484
485 // wxString version
486 WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path);
487
488 WXDLLIMPEXP_BASE void wxDos2UnixFilename(wxChar *s);
489
490 WXDLLIMPEXP_BASE void wxUnix2DosFilename(wxChar *s);
491
492 // Strip the extension, in situ
493 WXDLLIMPEXP_BASE void wxStripExtension(wxChar *buffer);
494 WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer);
495
496 // Get a temporary filename
497 WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL);
498 WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf);
499
500 // Expand file name (~/ and ${OPENWINHOME}/ stuff)
501 WXDLLIMPEXP_BASE wxChar* wxExpandPath(wxChar *dest, const wxChar *path);
502 WXDLLIMPEXP_BASE bool wxExpandPath(wxString& dest, const wxChar *path);
503
504 // Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
505 // and make (if under the home tree) relative to home
506 // [caller must copy-- volatile]
507 WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename,
508 const wxString& envname = wxEmptyString,
509 const wxString& user = wxEmptyString);
510
511 // Destructive removal of /./ and /../ stuff
512 WXDLLIMPEXP_BASE wxChar* wxRealPath(wxChar *path);
513
514 // Allocate a copy of the full absolute path
515 WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path);
516
517 // Get first file name matching given wild card.
518 // Flags are reserved for future use.
519 #define wxFILE 1
520 #define wxDIR 2
521 WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE);
522 WXDLLIMPEXP_BASE wxString wxFindNextFile();
523
524 // Does the pattern contain wildcards?
525 WXDLLIMPEXP_BASE bool wxIsWild(const wxString& pattern);
526
527 // Does the pattern match the text (usually a filename)?
528 // If dot_special is true, doesn't match * against . (eliminating
529 // `hidden' dot files)
530 WXDLLIMPEXP_BASE bool wxMatchWild(const wxString& pattern, const wxString& text, bool dot_special = true);
531
532 // Concatenate two files to form third
533 WXDLLIMPEXP_BASE bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
534
535 // Copy file1 to file2
536 WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& file1, const wxString& file2,
537 bool overwrite = true);
538
539 // Remove file
540 WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
541
542 // Rename file
543 WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite = true);
544
545 // Get current working directory.
546 #if WXWIN_COMPATIBILITY_2_6
547 // If buf is NULL, allocates space using new, else
548 // copies into buf.
549 // IMPORTANT NOTE getcwd is know not to work under some releases
550 // of Win32s 1.3, according to MS release notes!
551 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000) );
552 // new and preferred version of wxGetWorkingDirectory
553 // NB: can't have the same name because of overloading ambiguity
554 #endif // WXWIN_COMPATIBILITY_2_6
555 WXDLLIMPEXP_BASE wxString wxGetCwd();
556
557 // Set working directory
558 WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d);
559
560 // Make directory
561 WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777);
562
563 // Remove directory. Flags reserved for future use.
564 WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0);
565
566 // Return the type of an open file
567 WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd);
568 WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp);
569
570 #if WXWIN_COMPATIBILITY_2_6
571 // compatibility defines, don't use in new code
572 wxDEPRECATED( inline bool wxPathExists(const wxChar *pszPathName) );
573 inline bool wxPathExists(const wxChar *pszPathName)
574 {
575 return wxDirExists(pszPathName);
576 }
577 #endif //WXWIN_COMPATIBILITY_2_6
578
579 // permissions; these functions work both on files and directories:
580 WXDLLIMPEXP_BASE bool wxIsWritable(const wxString &path);
581 WXDLLIMPEXP_BASE bool wxIsReadable(const wxString &path);
582 WXDLLIMPEXP_BASE bool wxIsExecutable(const wxString &path);
583
584 // ----------------------------------------------------------------------------
585 // separators in file names
586 // ----------------------------------------------------------------------------
587
588 // between file name and extension
589 #define wxFILE_SEP_EXT wxT('.')
590
591 // between drive/volume name and the path
592 #define wxFILE_SEP_DSK wxT(':')
593
594 // between the path components
595 #define wxFILE_SEP_PATH_DOS wxT('\\')
596 #define wxFILE_SEP_PATH_UNIX wxT('/')
597 #define wxFILE_SEP_PATH_MAC wxT(':')
598 #define wxFILE_SEP_PATH_VMS wxT('.') // VMS also uses '[' and ']'
599
600 // separator in the path list (as in PATH environment variable)
601 // there is no PATH variable in Classic Mac OS so just use the
602 // semicolon (it must be different from the file name separator)
603 // NB: these are strings and not characters on purpose!
604 #define wxPATH_SEP_DOS wxT(";")
605 #define wxPATH_SEP_UNIX wxT(":")
606 #define wxPATH_SEP_MAC wxT(";")
607
608 // platform independent versions
609 #if defined(__UNIX__) && !defined(__OS2__)
610 // CYGWIN also uses UNIX settings
611 #define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
612 #define wxPATH_SEP wxPATH_SEP_UNIX
613 #elif defined(__MAC__)
614 #define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
615 #define wxPATH_SEP wxPATH_SEP_MAC
616 #else // Windows and OS/2
617 #define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
618 #define wxPATH_SEP wxPATH_SEP_DOS
619 #endif // Unix/Windows
620
621 // this is useful for wxString::IsSameAs(): to compare two file names use
622 // filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE)
623 #if defined(__UNIX__) && !defined(__DARWIN__) && !defined(__OS2__)
624 #define wxARE_FILENAMES_CASE_SENSITIVE true
625 #else // Windows, Mac OS and OS/2
626 #define wxARE_FILENAMES_CASE_SENSITIVE false
627 #endif // Unix/Windows
628
629 // is the char a path separator?
630 inline bool wxIsPathSeparator(wxChar c)
631 {
632 // under DOS/Windows we should understand both Unix and DOS file separators
633 #if ( defined(__UNIX__) && !defined(__OS2__) )|| defined(__MAC__)
634 return c == wxFILE_SEP_PATH;
635 #else
636 return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX;
637 #endif
638 }
639
640 // does the string ends with path separator?
641 WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxChar *pszFileName);
642
643 // split the full path into path (including drive for DOS), name and extension
644 // (understands both '/' and '\\')
645 WXDLLIMPEXP_BASE void wxSplitPath(const wxChar *pszFileName,
646 wxString *pstrPath,
647 wxString *pstrName,
648 wxString *pstrExt);
649
650 // find a file in a list of directories, returns false if not found
651 WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile);
652
653 // Get the OS directory if appropriate (such as the Windows directory).
654 // On non-Windows platform, probably just return the empty string.
655 WXDLLIMPEXP_BASE wxString wxGetOSDirectory();
656
657 #if wxUSE_DATETIME
658
659 // Get file modification time
660 WXDLLIMPEXP_BASE time_t wxFileModificationTime(const wxString& filename);
661
662 #endif // wxUSE_DATETIME
663
664 // Parses the wildCard, returning the number of filters.
665 // Returns 0 if none or if there's a problem,
666 // The arrays will contain an equal number of items found before the error.
667 // wildCard is in the form:
668 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
669 WXDLLIMPEXP_BASE int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
670
671 // ----------------------------------------------------------------------------
672 // classes
673 // ----------------------------------------------------------------------------
674
675 #ifdef __UNIX__
676
677 // set umask to the given value in ctor and reset it to the old one in dtor
678 class WXDLLIMPEXP_BASE wxUmaskChanger
679 {
680 public:
681 // change the umask to the given one if it is not -1: this allows to write
682 // the same code whether you really want to change umask or not, as is in
683 // wxFileConfig::Flush() for example
684 wxUmaskChanger(int umaskNew)
685 {
686 m_umaskOld = umaskNew == -1 ? -1 : (int)umask((mode_t)umaskNew);
687 }
688
689 ~wxUmaskChanger()
690 {
691 if ( m_umaskOld != -1 )
692 umask((mode_t)m_umaskOld);
693 }
694
695 private:
696 int m_umaskOld;
697 };
698
699 // this macro expands to an "anonymous" wxUmaskChanger object under Unix and
700 // nothing elsewhere
701 #define wxCHANGE_UMASK(m) wxUmaskChanger wxMAKE_UNIQUE_NAME(umaskChanger_)(m)
702
703 #else // !__UNIX__
704
705 #define wxCHANGE_UMASK(m)
706
707 #endif // __UNIX__/!__UNIX__
708
709
710 // Path searching
711 class WXDLLIMPEXP_BASE wxPathList : public wxArrayString
712 {
713 public:
714 wxPathList() {}
715 wxPathList(const wxArrayString &arr)
716 { Add(arr); }
717
718 // Adds all paths in environment variable
719 void AddEnvList(const wxString& envVariable);
720
721 // Adds given path to this list
722 bool Add(const wxString& path);
723 void Add(const wxArrayString &paths);
724
725 // Find the first full path for which the file exists
726 wxString FindValidPath(const wxString& filename) const;
727
728 // Find the first full path for which the file exists; ensure it's an
729 // absolute path that gets returned.
730 wxString FindAbsoluteValidPath(const wxString& filename) const;
731
732 // Given full path and filename, add path to list
733 bool EnsureFileAccessible(const wxString& path);
734
735 #if WXWIN_COMPATIBILITY_2_6
736 // Returns true if the path is in the list
737 wxDEPRECATED( bool Member(const wxString& path) const );
738 #endif
739 };
740
741 #endif // _WX_FILEFN_H_

  ViewVC Help
Powered by ViewVC 1.1.22