Coverage Report

Created: 2025-09-27 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wxwidgets/include/wx/filefn.h
Line
Count
Source
1
/////////////////////////////////////////////////////////////////////////////
2
// Name:        wx/filefn.h
3
// Purpose:     File- and directory-related functions
4
// Author:      Julian Smart
5
// Created:     29/01/98
6
// Copyright:   (c) 1998 Julian Smart
7
// Licence:     wxWindows licence
8
/////////////////////////////////////////////////////////////////////////////
9
10
#ifndef   _FILEFN_H_
11
#define   _FILEFN_H_
12
13
#include "wx/arrstr.h"
14
15
#include <time.h>
16
17
#include <sys/types.h>
18
#include <sys/stat.h>
19
20
#if defined(__UNIX__)
21
    #include <unistd.h>
22
    #include <dirent.h>
23
#endif
24
25
#if defined(__WINDOWS__)
26
#if !defined( __GNUWIN32__ ) && !defined(__CYGWIN__)
27
    #include <direct.h>
28
    #include <dos.h>
29
    #include <io.h>
30
#endif // __WINDOWS__
31
#endif // native Win compiler
32
33
#include  <fcntl.h>       // O_RDONLY &c
34
35
// ----------------------------------------------------------------------------
36
// constants
37
// ----------------------------------------------------------------------------
38
39
// MSVC doesn't define mode_t, so do it ourselves unless someone else
40
// had already predefined it.
41
#if defined(__VISUALC__) && !defined(wxHAS_MODE_T)
42
    #define wxHAS_MODE_T
43
    typedef int mode_t;
44
#endif
45
46
// define off_t
47
#include  <sys/types.h>
48
49
#if defined(__VISUALC__)
50
    typedef _off_t off_t;
51
#endif
52
53
enum wxSeekMode
54
{
55
  wxFromStart,
56
  wxFromCurrent,
57
  wxFromEnd
58
};
59
60
enum wxFileKind
61
{
62
  wxFILE_KIND_UNKNOWN,
63
  wxFILE_KIND_DISK,     // a file supporting seeking to arbitrary offsets
64
  wxFILE_KIND_TERMINAL, // a tty
65
  wxFILE_KIND_PIPE      // a pipe
66
};
67
68
// we redefine these constants here because S_IREAD &c are _not_ standard
69
// however, we do assume that the values correspond to the Unix umask bits
70
enum wxPosixPermissions
71
{
72
    // standard Posix names for these permission flags:
73
    wxS_IRUSR = 00400,
74
    wxS_IWUSR = 00200,
75
    wxS_IXUSR = 00100,
76
77
    wxS_IRGRP = 00040,
78
    wxS_IWGRP = 00020,
79
    wxS_IXGRP = 00010,
80
81
    wxS_IROTH = 00004,
82
    wxS_IWOTH = 00002,
83
    wxS_IXOTH = 00001,
84
85
    // longer but more readable synonyms for the constants above:
86
    wxPOSIX_USER_READ = wxS_IRUSR,
87
    wxPOSIX_USER_WRITE = wxS_IWUSR,
88
    wxPOSIX_USER_EXECUTE = wxS_IXUSR,
89
90
    wxPOSIX_GROUP_READ = wxS_IRGRP,
91
    wxPOSIX_GROUP_WRITE = wxS_IWGRP,
92
    wxPOSIX_GROUP_EXECUTE = wxS_IXGRP,
93
94
    wxPOSIX_OTHERS_READ = wxS_IROTH,
95
    wxPOSIX_OTHERS_WRITE = wxS_IWOTH,
96
    wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH,
97
98
    // default mode for the new files: allow reading/writing them to everybody but
99
    // the effective file mode will be set after anding this value with umask and
100
    // so won't include wxS_IW{GRP,OTH} for the default 022 umask value
101
    wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \
102
                   wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \
103
                   wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE),
104
105
    // default mode for the new directories (see wxFileName::Mkdir): allow
106
    // reading/writing/executing them to everybody, but just like wxS_DEFAULT
107
    // the effective directory mode will be set after anding this value with umask
108
    wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \
109
                       wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \
110
                       wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE)
111
};
112
113
// ----------------------------------------------------------------------------
114
// declare our versions of low level file functions: some compilers prepend
115
// underscores to the usual names, some also have Unicode versions of them
116
// ----------------------------------------------------------------------------
117
118
#if defined(__WINDOWS__) && \
119
      ( \
120
        defined(__VISUALC__) || \
121
        defined(__MINGW64_TOOLCHAIN__) || \
122
        (defined(__MINGW32__) && !defined(__WINE__)) \
123
      )
124
125
    // temporary defines just used immediately below
126
    #undef wxHAS_HUGE_FILES
127
    #undef wxHAS_HUGE_STDIO_FILES
128
129
    // detect compilers which have support for huge files
130
    #if defined(__VISUALC__)
131
        #define wxHAS_HUGE_FILES 1
132
    #elif defined(__MINGW32__)
133
        #define wxHAS_HUGE_FILES 1
134
    #elif defined(_LARGE_FILES)
135
        #define wxHAS_HUGE_FILES 1
136
    #endif
137
138
    // detect compilers which have support for huge stdio files
139
    #if defined(__VISUALC__)
140
        #define wxHAS_HUGE_STDIO_FILES
141
        #define wxFseek _fseeki64
142
        #define wxFtell _ftelli64
143
    #elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
144
        #define wxHAS_HUGE_STDIO_FILES
145
146
        wxDECL_FOR_STRICT_MINGW32(int, fseeko64, (FILE*, long long, int))
147
        #define wxFseek fseeko64
148
149
        #ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
150
            // Unfortunately ftello64() is not defined in the library for
151
            // whatever reason but as an inline function, so define wxFtell()
152
            // here similarly.
153
            inline long long wxFtell(FILE* fp)
154
            {
155
                fpos_t pos;
156
                if ( fgetpos(fp, &pos) != 0 )
157
                    return -1LL;
158
159
                // Unfortunately our interface assumes that the file position
160
                // is representable as "long long", so we have to get it from
161
                // fpos_t, even though it's an opaque type. And its exact
162
                // representation has changed in MinGW, so we have to test for
163
                // mingwrt version.
164
                #if wxCHECK_MINGW32_VERSION(5, 2)
165
                    // In 5.2.2 it's a union with a __value field.
166
                    return pos.__value;
167
                #else
168
                    // Up to 5.1.1 it was a simple typedef.
169
                    return pos;
170
                #endif
171
            }
172
        #else
173
            #define wxFtell ftello64
174
        #endif
175
    #endif
176
177
178
    // types
179
180
    #ifdef wxHAS_HUGE_FILES
181
        typedef wxLongLong_t wxFileOffset;
182
        #define wxFileOffsetFmtSpec wxLongLongFmtSpec
183
    #else
184
        typedef off_t wxFileOffset;
185
    #endif
186
187
188
    #define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s)
189
190
    #ifdef wxHAS_HUGE_FILES
191
        #define wxStructStat struct _stati64
192
    #else
193
        #define wxStructStat struct _stat
194
    #endif
195
196
197
    // functions
198
199
    // MSVC and compatible compilers prepend underscores to the POSIX function
200
    // names, other compilers don't and even if their later versions usually do
201
    // define the versions with underscores for MSVC compatibility, it's better
202
    // to avoid using them as they're not present in earlier versions and
203
    // always using the native functions spelling is easier than testing for
204
    // the versions
205
    #if defined(__MINGW64_TOOLCHAIN__)
206
        #define wxPOSIX_IDENT(func)    ::func
207
    #else // by default assume MSVC-compatible names
208
        #define wxPOSIX_IDENT(func)    _ ## func
209
        #define wxHAS_UNDERSCORES_IN_POSIX_IDENTS
210
    #endif
211
212
    // first functions not working with strings, i.e. without ANSI/Unicode
213
    // complications
214
    #define   wxClose      wxPOSIX_IDENT(close)
215
216
    #define wxRead         wxPOSIX_IDENT(read)
217
    #define wxWrite        wxPOSIX_IDENT(write)
218
219
    #ifdef wxHAS_HUGE_FILES
220
        #ifndef __MINGW64_TOOLCHAIN__
221
            #define   wxSeek       wxPOSIX_IDENT(lseeki64)
222
            #define   wxLseek      wxPOSIX_IDENT(lseeki64)
223
            #define   wxTell       wxPOSIX_IDENT(telli64)
224
        #else
225
            // unfortunately, mingw-W64 is somewhat inconsistent...
226
            #define   wxSeek       _lseeki64
227
            #define   wxLseek      _lseeki64
228
            #define   wxTell       _telli64
229
        #endif
230
    #else // !wxHAS_HUGE_FILES
231
        #define   wxSeek       wxPOSIX_IDENT(lseek)
232
        #define   wxLseek      wxPOSIX_IDENT(lseek)
233
        #define   wxTell       wxPOSIX_IDENT(tell)
234
    #endif // wxHAS_HUGE_FILES/!wxHAS_HUGE_FILES
235
236
237
     #define   wxFsync      _commit
238
239
     // could be already defined by configure (Cygwin)
240
     #ifndef HAVE_FSYNC
241
         #define HAVE_FSYNC
242
     #endif
243
244
    #define   wxEof        wxPOSIX_IDENT(eof)
245
246
    // then the functions taking strings
247
    #define wxCRT_Open          _wopen
248
249
    wxDECL_FOR_STRICT_MINGW32(int, _wopen, (const wchar_t*, int, ...))
250
    wxDECL_FOR_STRICT_MINGW32(int, _waccess, (const wchar_t*, int))
251
    wxDECL_FOR_STRICT_MINGW32(int, _wchmod, (const wchar_t*, int))
252
    wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*))
253
    wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*))
254
    wxDECL_FOR_STRICT_MINGW32(int, _wstati64, (const wchar_t*, struct _stati64*))
255
256
    #define   wxCRT_Access      _waccess
257
    #define   wxCRT_Chmod       _wchmod
258
    #define   wxCRT_MkDir       _wmkdir
259
    #define   wxCRT_RmDir       _wrmdir
260
    #ifdef wxHAS_HUGE_FILES
261
        #define   wxCRT_Stat        _wstati64
262
    #else
263
        #define   wxCRT_Stat        _wstat
264
    #endif
265
266
267
    // constants (unless already defined by the user code)
268
    #ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS
269
        #ifndef O_RDONLY
270
            #define   O_RDONLY    _O_RDONLY
271
            #define   O_WRONLY    _O_WRONLY
272
            #define   O_RDWR      _O_RDWR
273
            #define   O_EXCL      _O_EXCL
274
            #define   O_CREAT     _O_CREAT
275
            #define   O_BINARY    _O_BINARY
276
        #endif
277
278
        #ifndef S_IFMT
279
            #define   S_IFMT      _S_IFMT
280
            #define   S_IFDIR     _S_IFDIR
281
            #define   S_IFREG     _S_IFREG
282
        #endif
283
    #endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS
284
285
    #ifdef wxHAS_HUGE_FILES
286
        // wxFile is present and supports large files.
287
        #if wxUSE_FILE
288
            #define wxHAS_LARGE_FILES
289
        #endif
290
        // wxFFile is present and supports large files
291
        #if wxUSE_FFILE && defined wxHAS_HUGE_STDIO_FILES
292
            #define wxHAS_LARGE_FFILES
293
        #endif
294
    #endif
295
296
    // private defines, undefine so that nobody gets tempted to use
297
    #undef wxHAS_HUGE_FILES
298
    #undef wxHAS_HUGE_STDIO_FILES
299
#else // Unix or Windows using unknown compiler, assume POSIX supported
300
    typedef off_t wxFileOffset;
301
    #ifdef HAVE_LARGEFILE_SUPPORT
302
        #define wxFileOffsetFmtSpec wxLongLongFmtSpec
303
        wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
304
                                BadFileSizeType );
305
        // wxFile is present and supports large files
306
        #if wxUSE_FILE
307
            #define wxHAS_LARGE_FILES
308
        #endif
309
        // wxFFile is present and supports large files
310
        #if wxUSE_FFILE && (SIZEOF_LONG == 8 || defined HAVE_FSEEKO)
311
            #define wxHAS_LARGE_FFILES
312
        #endif
313
        #ifdef HAVE_FSEEKO
314
0
            #define wxFseek fseeko
315
0
            #define wxFtell ftello
316
        #endif
317
    #else
318
        #define wxFileOffsetFmtSpec wxT("")
319
    #endif
320
    // functions
321
0
    #define   wxClose      close
322
0
    #define   wxRead       ::read
323
0
    #define   wxWrite      ::write
324
    #define   wxLseek      lseek
325
0
    #define   wxSeek       lseek
326
0
    #define   wxFsync      fsync
327
    #define   wxEof        eof
328
    #define   wxCRT_MkDir      mkdir
329
0
    #define   wxCRT_RmDir      rmdir
330
331
0
    #define   wxTell(fd)   lseek(fd, 0, SEEK_CUR)
332
333
0
    #define   wxStructStat struct stat
334
335
0
    #define   wxCRT_Open       open
336
0
    #define   wxCRT_Stat       stat
337
0
    #define   wxCRT_Lstat      lstat
338
0
    #define   wxCRT_Access     access
339
0
    #define   wxCRT_Chmod      chmod
340
341
0
    #define   wxCRT_Readlink   readlink
342
343
    #define wxHAS_NATIVE_LSTAT
344
    #define wxHAS_NATIVE_READLINK
345
#endif // platforms
346
347
// if the platform doesn't have symlinks, define wxCRT_Lstat to be the same as
348
// wxCRT_Stat to avoid #ifdefs in the code using it
349
#ifndef wxHAS_NATIVE_LSTAT
350
    #define wxCRT_Lstat wxCRT_Stat
351
#endif
352
353
// define wxFseek/wxFtell to large file versions if available (done above) or
354
// to fseek/ftell if not, to save ifdefs in using code
355
#ifndef wxFseek
356
    #define wxFseek fseek
357
#endif
358
#ifndef wxFtell
359
    #define wxFtell ftell
360
#endif
361
362
inline int wxAccess(const wxString& path, mode_t mode)
363
0
    { return wxCRT_Access(path.fn_str(), mode); }
364
inline int wxChmod(const wxString& path, mode_t mode)
365
0
    { return wxCRT_Chmod(path.fn_str(), mode); }
366
inline int wxOpen(const wxString& path, int flags, mode_t mode)
367
0
    { return wxCRT_Open(path.fn_str(), flags, mode); }
368
369
#if defined(wxHAS_NATIVE_READLINK)
370
inline ssize_t wxReadlink(const wxString& path, char* buf, int size)
371
0
    { return wxCRT_Readlink(path.fn_str(), buf, size); }
372
#endif
373
374
inline int wxStat(const wxString& path, wxStructStat *buf)
375
0
    { return wxCRT_Stat(path.fn_str(), buf); }
376
inline int wxLstat(const wxString& path, wxStructStat *buf)
377
0
    { return wxCRT_Lstat(path.fn_str(), buf); }
378
inline int wxRmDir(const wxString& path)
379
0
    { return wxCRT_RmDir(path.fn_str()); }
380
#if (defined(__WINDOWS__) && !defined(__CYGWIN__))
381
inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0)
382
    { return wxCRT_MkDir(path.fn_str()); }
383
#else
384
inline int wxMkDir(const wxString& path, mode_t mode)
385
0
    { return wxCRT_MkDir(path.fn_str(), mode); }
386
#endif
387
388
#ifdef O_BINARY
389
    #define wxO_BINARY O_BINARY
390
#else
391
0
    #define wxO_BINARY 0
392
#endif
393
394
const int wxInvalidOffset = -1;
395
396
// ----------------------------------------------------------------------------
397
// functions
398
// ----------------------------------------------------------------------------
399
WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename);
400
401
// does the path exist? (may have or not '/' or '\\' at the end)
402
WXDLLIMPEXP_BASE bool wxDirExists(const wxString& pathName);
403
404
WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename);
405
406
// Get filename
407
WXDLLIMPEXP_BASE wxChar* wxFileNameFromPath(wxChar *path);
408
WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path);
409
410
// Get directory
411
WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path);
412
413
// Get first file name matching given wild card.
414
// Flags are reserved for future use.
415
0
#define wxFILE  1
416
0
#define wxDIR   2
417
WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxString& spec, int flags = wxFILE);
418
WXDLLIMPEXP_BASE wxString wxFindNextFile();
419
420
// Does the pattern contain wildcards?
421
WXDLLIMPEXP_BASE bool wxIsWild(const wxString& pattern);
422
423
// Does the pattern match the text (usually a filename)?
424
// If dot_special is true, doesn't match * against . (eliminating
425
// `hidden' dot files)
426
WXDLLIMPEXP_BASE bool wxMatchWild(const wxString& pattern,  const wxString& text, bool dot_special = true);
427
428
// Concatenate two files to form third
429
WXDLLIMPEXP_BASE bool wxConcatFiles(const wxString& src1, const wxString& src2, const wxString& dest);
430
431
// Copy file
432
WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& src, const wxString& dest,
433
                                 bool overwrite = true);
434
435
// Remove file
436
WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
437
438
// Rename file
439
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& oldpath, const wxString& newpath, bool overwrite = true);
440
441
// Get current working directory.
442
WXDLLIMPEXP_BASE wxString wxGetCwd();
443
444
// Set working directory
445
WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d);
446
447
// Make directory
448
WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT);
449
450
// Remove directory. Flags reserved for future use.
451
WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0);
452
453
// Return the type of an open file
454
WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd);
455
WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp);
456
457
// permissions; these functions work both on files and directories:
458
WXDLLIMPEXP_BASE bool wxIsWritable(const wxString &path);
459
WXDLLIMPEXP_BASE bool wxIsReadable(const wxString &path);
460
WXDLLIMPEXP_BASE bool wxIsExecutable(const wxString &path);
461
462
// ----------------------------------------------------------------------------
463
// separators in file names
464
// ----------------------------------------------------------------------------
465
466
// between file name and extension
467
0
#define wxFILE_SEP_EXT        wxT('.')
468
469
// between drive/volume name and the path
470
0
#define wxFILE_SEP_DSK        wxT(':')
471
472
// between the path components
473
52.2k
#define wxFILE_SEP_PATH_DOS   wxT('\\')
474
50.1k
#define wxFILE_SEP_PATH_UNIX  wxT('/')
475
0
#define wxFILE_SEP_PATH_MAC   wxT(':')
476
0
#define wxFILE_SEP_PATH_VMS   wxT('.') // VMS also uses '[' and ']'
477
478
// separator in the path list (as in PATH environment variable)
479
// there is no PATH variable in Classic Mac OS so just use the
480
// semicolon (it must be different from the file name separator)
481
// NB: these are strings and not characters on purpose!
482
#define wxPATH_SEP_DOS        wxT(";")
483
0
#define wxPATH_SEP_UNIX       wxT(":")
484
#define wxPATH_SEP_MAC        wxT(";")
485
486
// platform independent versions
487
#if defined(__UNIX__)
488
  // CYGWIN also uses UNIX settings
489
0
  #define wxFILE_SEP_PATH     wxFILE_SEP_PATH_UNIX
490
0
  #define wxPATH_SEP          wxPATH_SEP_UNIX
491
#elif defined(__MAC__)
492
  #define wxFILE_SEP_PATH     wxFILE_SEP_PATH_MAC
493
  #define wxPATH_SEP          wxPATH_SEP_MAC
494
#else   // Windows
495
  #define wxFILE_SEP_PATH     wxFILE_SEP_PATH_DOS
496
  #define wxPATH_SEP          wxPATH_SEP_DOS
497
#endif  // Unix/Windows
498
499
// this is useful for wxString::IsSameAs(): to compare two file names use
500
// filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE)
501
#if defined(__UNIX__) && !defined(__DARWIN__)
502
  #define wxARE_FILENAMES_CASE_SENSITIVE  true
503
#else   // Windows and OSX
504
  #define wxARE_FILENAMES_CASE_SENSITIVE  false
505
#endif  // Unix/Windows
506
507
// is the char a path separator?
508
inline bool wxIsPathSeparator(wxChar c)
509
0
{
510
    // under DOS/Windows we should understand both Unix and DOS file separators
511
0
#if defined(__UNIX__) || defined(__MAC__)
512
0
    return c == wxFILE_SEP_PATH;
513
#else
514
    return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX;
515
#endif
516
0
}
517
518
// does the string ends with path separator?
519
WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxString& filename);
520
521
// find a file in a list of directories, returns false if not found
522
WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile);
523
524
// Get the OS directory if appropriate (such as the Windows directory).
525
// On non-Windows platform, probably just return the empty string.
526
WXDLLIMPEXP_BASE wxString wxGetOSDirectory();
527
528
#if wxUSE_DATETIME
529
530
// Get file modification time
531
WXDLLIMPEXP_BASE time_t wxFileModificationTime(const wxString& filename);
532
533
#endif // wxUSE_DATETIME
534
535
// Parses the wildCard, returning the number of filters.
536
// Returns 0 if none or if there's a problem,
537
// The arrays will contain an equal number of items found before the error.
538
// wildCard is in the form:
539
// "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
540
WXDLLIMPEXP_BASE int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
541
542
// ----------------------------------------------------------------------------
543
// classes
544
// ----------------------------------------------------------------------------
545
546
#ifdef __UNIX__
547
548
// set umask to the given value in ctor and reset it to the old one in dtor
549
class WXDLLIMPEXP_BASE wxUmaskChanger
550
{
551
public:
552
    // change the umask to the given one if it is not -1: this allows to write
553
    // the same code whether you really want to change umask or not, as is in
554
    // wxFileConfig::Flush() for example
555
    wxUmaskChanger(int umaskNew)
556
0
    {
557
0
        m_umaskOld = umaskNew == -1 ? -1 : (int)umask((mode_t)umaskNew);
558
0
    }
559
560
    ~wxUmaskChanger()
561
0
    {
562
0
        if ( m_umaskOld != -1 )
563
0
            umask((mode_t)m_umaskOld);
564
0
    }
565
566
private:
567
    int m_umaskOld;
568
};
569
570
// this macro expands to an "anonymous" wxUmaskChanger object under Unix and
571
// nothing elsewhere
572
0
#define wxCHANGE_UMASK(m) wxUmaskChanger wxMAKE_UNIQUE_NAME(umaskChanger_)(m)
573
574
#else // !__UNIX__
575
576
#define wxCHANGE_UMASK(m)
577
578
#endif // __UNIX__/!__UNIX__
579
580
581
// Path searching
582
class WXDLLIMPEXP_BASE wxPathList : public wxArrayString
583
{
584
public:
585
0
    wxPathList() = default;
586
    wxPathList(const wxArrayString &arr)
587
0
        { Add(arr); }
588
589
    // Adds all paths in environment variable
590
    void AddEnvList(const wxString& envVariable);
591
592
    // Adds given path to this list
593
    bool Add(const wxString& path);
594
    void Add(const wxArrayString &paths);
595
596
    // Find the first full path for which the file exists
597
    wxString FindValidPath(const wxString& filename) const;
598
599
    // Find the first full path for which the file exists; ensure it's an
600
    // absolute path that gets returned.
601
    wxString FindAbsoluteValidPath(const wxString& filename) const;
602
603
    // Given full path and filename, add path to list
604
    bool EnsureFileAccessible(const wxString& path);
605
};
606
607
#endif // _WX_FILEFN_H_