1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-03 12:39:45 -04:00
|
|
|
// Name: wx/filefn.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose: File- and directory-related functions
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29/01/98
|
|
|
|
// Copyright: (c) 1998 Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _FILEFN_H_
|
|
|
|
#define _FILEFN_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-08-20 18:52:21 -04:00
|
|
|
#include "wx/list.h"
|
2004-06-20 05:14:18 -04:00
|
|
|
#include "wx/arrstr.h"
|
1998-07-15 14:40:37 -04:00
|
|
|
|
2004-09-25 18:44:19 -04:00
|
|
|
#ifdef __WXWINCE__
|
|
|
|
#include "wx/msw/wince/time.h"
|
|
|
|
#include "wx/msw/private.h"
|
|
|
|
#else
|
|
|
|
#include <time.h>
|
2002-12-07 10:41:13 -05:00
|
|
|
#endif
|
2000-01-18 20:00:25 -05:00
|
|
|
|
2012-04-05 14:40:11 -04:00
|
|
|
#ifndef __WXWINCE__
|
2004-09-25 18:44:19 -04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__UNIX__)
|
2004-09-25 18:44:19 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
2012-04-05 14:40:11 -04:00
|
|
|
#if !defined( __GNUWIN32__ ) && !defined(__WXWINCE__) && !defined(__CYGWIN__)
|
2004-09-25 18:44:19 -04:00
|
|
|
#include <direct.h>
|
|
|
|
#include <dos.h>
|
|
|
|
#include <io.h>
|
|
|
|
#endif // __WINDOWS__
|
|
|
|
#endif // native Win compiler
|
|
|
|
|
|
|
|
#if defined(__DOS__)
|
|
|
|
#ifdef __DJGPP__
|
|
|
|
#include <io.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
|
|
|
|
// this (3.1 I believe) and how to test for it.
|
|
|
|
// If this works for Borland 4.0 as well, then no worries.
|
|
|
|
#include <dir.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __WXWINCE__
|
|
|
|
#include <fcntl.h> // O_RDONLY &c
|
|
|
|
#endif
|
2012-01-14 20:05:28 -05:00
|
|
|
|
1998-07-14 18:15:29 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2014-05-16 09:01:23 -04:00
|
|
|
#if defined(__VISUALC__)
|
2007-06-10 13:14:14 -04:00
|
|
|
typedef int mode_t;
|
|
|
|
#endif
|
|
|
|
|
2002-12-07 10:41:13 -05:00
|
|
|
#ifdef __WXWINCE__
|
|
|
|
typedef long off_t;
|
|
|
|
#else
|
2004-09-25 18:44:19 -04:00
|
|
|
// define off_t
|
|
|
|
#if !defined(__WXMAC__) || defined(__UNIX__) || defined(__MACH__)
|
|
|
|
#include <sys/types.h>
|
|
|
|
#else
|
|
|
|
typedef long off_t;
|
|
|
|
#endif
|
1999-01-01 11:22:21 -05:00
|
|
|
#endif
|
1998-07-14 18:15:29 -04:00
|
|
|
|
2013-10-14 11:08:06 -04:00
|
|
|
#if defined(__VISUALC__) && !defined(__WXWINCE__)
|
1999-02-03 11:48:12 -05:00
|
|
|
typedef _off_t off_t;
|
2003-05-02 07:21:03 -04:00
|
|
|
#elif defined(__SYMANTEC__)
|
1999-02-03 11:48:12 -05:00
|
|
|
typedef long off_t;
|
1999-01-07 03:43:47 -05:00
|
|
|
#endif
|
|
|
|
|
1999-02-09 12:04:29 -05:00
|
|
|
enum wxSeekMode
|
|
|
|
{
|
1998-07-14 18:15:29 -04:00
|
|
|
wxFromStart,
|
|
|
|
wxFromCurrent,
|
|
|
|
wxFromEnd
|
1999-02-09 12:04:29 -05:00
|
|
|
};
|
1998-07-14 18:15:29 -04:00
|
|
|
|
2005-02-12 16:53:51 -05:00
|
|
|
enum wxFileKind
|
2005-02-11 07:39:03 -05:00
|
|
|
{
|
2005-02-12 16:53:51 -05:00
|
|
|
wxFILE_KIND_UNKNOWN,
|
|
|
|
wxFILE_KIND_DISK, // a file supporting seeking to arbitrary offsets
|
|
|
|
wxFILE_KIND_TERMINAL, // a tty
|
|
|
|
wxFILE_KIND_PIPE // a pipe
|
2005-02-11 07:39:03 -05:00
|
|
|
};
|
|
|
|
|
2010-02-10 06:38:41 -05:00
|
|
|
// we redefine these constants here because S_IREAD &c are _not_ standard
|
|
|
|
// however, we do assume that the values correspond to the Unix umask bits
|
|
|
|
enum wxPosixPermissions
|
|
|
|
{
|
|
|
|
// standard Posix names for these permission flags:
|
|
|
|
wxS_IRUSR = 00400,
|
|
|
|
wxS_IWUSR = 00200,
|
|
|
|
wxS_IXUSR = 00100,
|
|
|
|
|
|
|
|
wxS_IRGRP = 00040,
|
|
|
|
wxS_IWGRP = 00020,
|
|
|
|
wxS_IXGRP = 00010,
|
|
|
|
|
|
|
|
wxS_IROTH = 00004,
|
|
|
|
wxS_IWOTH = 00002,
|
|
|
|
wxS_IXOTH = 00001,
|
|
|
|
|
|
|
|
// longer but more readable synonyms for the constants above:
|
|
|
|
wxPOSIX_USER_READ = wxS_IRUSR,
|
|
|
|
wxPOSIX_USER_WRITE = wxS_IWUSR,
|
|
|
|
wxPOSIX_USER_EXECUTE = wxS_IXUSR,
|
|
|
|
|
|
|
|
wxPOSIX_GROUP_READ = wxS_IRGRP,
|
|
|
|
wxPOSIX_GROUP_WRITE = wxS_IWGRP,
|
|
|
|
wxPOSIX_GROUP_EXECUTE = wxS_IXGRP,
|
|
|
|
|
|
|
|
wxPOSIX_OTHERS_READ = wxS_IROTH,
|
|
|
|
wxPOSIX_OTHERS_WRITE = wxS_IWOTH,
|
|
|
|
wxPOSIX_OTHERS_EXECUTE = wxS_IXOTH,
|
|
|
|
|
|
|
|
// default mode for the new files: allow reading/writing them to everybody but
|
|
|
|
// the effective file mode will be set after anding this value with umask and
|
|
|
|
// so won't include wxS_IW{GRP,OTH} for the default 022 umask value
|
|
|
|
wxS_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | \
|
|
|
|
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | \
|
|
|
|
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE),
|
|
|
|
|
|
|
|
// default mode for the new directories (see wxFileName::Mkdir): allow
|
|
|
|
// reading/writing/executing them to everybody, but just like wxS_DEFAULT
|
|
|
|
// the effective directory mode will be set after anding this value with umask
|
|
|
|
wxS_DIR_DEFAULT = (wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | \
|
|
|
|
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_WRITE | wxPOSIX_GROUP_EXECUTE | \
|
|
|
|
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_WRITE | wxPOSIX_OTHERS_EXECUTE)
|
|
|
|
};
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// declare our versions of low level file functions: some compilers prepend
|
|
|
|
// underscores to the usual names, some also have Unicode versions of them
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2004-09-25 18:44:19 -04:00
|
|
|
// Wrappers around Win32 api functions like CreateFile, ReadFile and such
|
|
|
|
// Implemented in filefnwce.cpp
|
2004-09-28 03:45:37 -04:00
|
|
|
#if defined( __WXWINCE__)
|
2004-09-25 18:44:19 -04:00
|
|
|
typedef __int64 wxFileOffset;
|
2010-07-03 10:24:17 -04:00
|
|
|
#define wxFileOffsetFmtSpec wxT("I64")
|
2007-06-10 13:14:14 -04:00
|
|
|
WXDLLIMPEXP_BASE int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode));
|
|
|
|
WXDLLIMPEXP_BASE int wxCRT_Access(const wxChar *name, int WXUNUSED(how));
|
2013-08-07 07:08:28 -04:00
|
|
|
WXDLLIMPEXP_BASE int wxCRT_Chmod(const wxChar *name, int WXUNUSED(how));
|
2007-06-06 11:56:44 -04:00
|
|
|
WXDLLIMPEXP_BASE int wxClose(int fd);
|
|
|
|
WXDLLIMPEXP_BASE int wxFsync(int WXUNUSED(fd));
|
|
|
|
WXDLLIMPEXP_BASE int wxRead(int fd, void *buf, unsigned int count);
|
|
|
|
WXDLLIMPEXP_BASE int wxWrite(int fd, const void *buf, unsigned int count);
|
|
|
|
WXDLLIMPEXP_BASE int wxEof(int fd);
|
|
|
|
WXDLLIMPEXP_BASE wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin);
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxLSeek wxSeek
|
2007-06-06 11:56:44 -04:00
|
|
|
WXDLLIMPEXP_BASE wxFileOffset wxTell(int fd);
|
2005-03-17 12:46:32 -05:00
|
|
|
|
2005-01-07 13:47:29 -05:00
|
|
|
// always Unicode under WinCE
|
2007-06-10 13:14:14 -04:00
|
|
|
#define wxCRT_MkDir _wmkdir
|
|
|
|
#define wxCRT_RmDir _wrmdir
|
|
|
|
#define wxCRT_Stat _wstat
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStructStat struct _stat
|
2014-05-15 19:56:58 -04:00
|
|
|
#elif defined(__WINDOWS__) && \
|
2006-10-23 16:39:09 -04:00
|
|
|
( \
|
2013-10-14 11:08:06 -04:00
|
|
|
defined(__VISUALC__) || \
|
2008-08-30 08:52:47 -04:00
|
|
|
defined(__MINGW64__) || \
|
2006-10-23 16:39:09 -04:00
|
|
|
(defined(__MINGW32__) && !defined(__WINE__) && \
|
|
|
|
wxCHECK_W32API_VERSION(0, 5)) || \
|
|
|
|
defined(__BORLANDC__) \
|
|
|
|
)
|
2004-09-26 09:18:46 -04:00
|
|
|
|
2009-12-22 16:22:59 -05:00
|
|
|
// temporary defines just used immediately below
|
2004-10-07 20:20:07 -04:00
|
|
|
#undef wxHAS_HUGE_FILES
|
2009-12-22 16:22:59 -05:00
|
|
|
#undef wxHAS_HUGE_STDIO_FILES
|
2006-10-23 16:39:09 -04:00
|
|
|
|
2006-10-27 07:27:38 -04:00
|
|
|
// detect compilers which have support for huge files
|
2013-10-14 11:08:06 -04:00
|
|
|
#if defined(__VISUALC__)
|
2006-10-27 20:20:47 -04:00
|
|
|
#define wxHAS_HUGE_FILES 1
|
2008-08-30 08:52:47 -04:00
|
|
|
#elif defined(__MINGW32__) || defined(__MINGW64__)
|
2013-09-30 19:49:21 -04:00
|
|
|
#define wxHAS_HUGE_FILES 1f
|
2006-10-24 08:08:05 -04:00
|
|
|
#elif defined(_LARGE_FILES)
|
|
|
|
#define wxHAS_HUGE_FILES 1
|
2004-09-25 18:44:19 -04:00
|
|
|
#endif
|
|
|
|
|
2009-12-22 16:22:59 -05:00
|
|
|
// detect compilers which have support for huge stdio files
|
|
|
|
#if wxCHECK_VISUALC_VERSION(8)
|
|
|
|
#define wxHAS_HUGE_STDIO_FILES
|
|
|
|
#define wxFseek _fseeki64
|
|
|
|
#define wxFtell _ftelli64
|
2009-12-30 12:38:22 -05:00
|
|
|
#elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
|
|
|
|
#define wxHAS_HUGE_STDIO_FILES
|
|
|
|
#define wxFseek fseeko64
|
|
|
|
#define wxFtell ftello64
|
2009-12-22 16:22:59 -05:00
|
|
|
#endif
|
|
|
|
|
2014-05-16 09:01:06 -04:00
|
|
|
// other Windows compilers (Borland) don't have huge file support (or at
|
|
|
|
// least not all functions needed for it by wx) currently
|
2006-10-24 08:08:05 -04:00
|
|
|
|
2009-04-25 09:52:58 -04:00
|
|
|
// types
|
|
|
|
|
2006-10-24 08:08:05 -04:00
|
|
|
#ifdef wxHAS_HUGE_FILES
|
2004-09-25 18:44:19 -04:00
|
|
|
typedef wxLongLong_t wxFileOffset;
|
|
|
|
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
|
|
|
#else
|
2004-09-26 09:18:46 -04:00
|
|
|
typedef off_t wxFileOffset;
|
2004-09-25 18:44:19 -04:00
|
|
|
#endif
|
|
|
|
|
2009-04-25 09:52:58 -04:00
|
|
|
// at least Borland 5.5 doesn't like "struct ::stat" so don't use the scope
|
|
|
|
// resolution operator present in wxPOSIX_IDENT for it
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#define wxPOSIX_STRUCT(s) struct s
|
|
|
|
#else
|
|
|
|
#define wxPOSIX_STRUCT(s) struct wxPOSIX_IDENT(s)
|
|
|
|
#endif
|
|
|
|
|
2014-05-16 09:01:06 -04:00
|
|
|
// Borland is special in that it uses _stat with Unicode functions (for
|
|
|
|
// MSVC compatibility?) but stat with ANSI ones
|
2009-04-25 09:52:58 -04:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#if wxHAS_HUGE_FILES
|
|
|
|
#define wxStructStat struct stati64
|
|
|
|
#else
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
#define wxStructStat struct _stat
|
|
|
|
#else
|
|
|
|
#define wxStructStat struct stat
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else // !__BORLANDC__
|
|
|
|
#ifdef wxHAS_HUGE_FILES
|
2014-05-16 09:01:06 -04:00
|
|
|
#define wxStructStat struct _stati64
|
2009-04-25 09:52:58 -04:00
|
|
|
#else
|
2014-05-16 09:01:06 -04:00
|
|
|
#define wxStructStat struct _stat
|
2009-04-25 09:52:58 -04:00
|
|
|
#endif
|
|
|
|
#endif // __BORLANDC__/!__BORLANDC__
|
|
|
|
|
2006-10-29 08:55:52 -05:00
|
|
|
|
|
|
|
// functions
|
|
|
|
|
|
|
|
// MSVC and compatible compilers prepend underscores to the POSIX function
|
|
|
|
// names, other compilers don't and even if their later versions usually do
|
|
|
|
// define the versions with underscores for MSVC compatibility, it's better
|
|
|
|
// to avoid using them as they're not present in earlier versions and
|
|
|
|
// always using the native functions spelling is easier than testing for
|
|
|
|
// the versions
|
2014-05-16 09:01:23 -04:00
|
|
|
#if defined(__BORLANDC__) || defined(__MINGW64__)
|
2006-10-29 08:55:52 -05:00
|
|
|
#define wxPOSIX_IDENT(func) ::func
|
|
|
|
#else // by default assume MSVC-compatible names
|
|
|
|
#define wxPOSIX_IDENT(func) _ ## func
|
|
|
|
#define wxHAS_UNDERSCORES_IN_POSIX_IDENTS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// first functions not working with strings, i.e. without ANSI/Unicode
|
|
|
|
// complications
|
|
|
|
#define wxClose wxPOSIX_IDENT(close)
|
2004-09-25 18:44:19 -04:00
|
|
|
|
2012-04-05 14:40:11 -04:00
|
|
|
#define wxRead wxPOSIX_IDENT(read)
|
|
|
|
#define wxWrite wxPOSIX_IDENT(write)
|
2006-10-29 08:55:52 -05:00
|
|
|
|
2006-10-24 08:08:05 -04:00
|
|
|
#ifdef wxHAS_HUGE_FILES
|
2008-05-31 08:44:40 -04:00
|
|
|
#ifndef __MINGW64__
|
|
|
|
#define wxSeek wxPOSIX_IDENT(lseeki64)
|
|
|
|
#define wxLseek wxPOSIX_IDENT(lseeki64)
|
|
|
|
#define wxTell wxPOSIX_IDENT(telli64)
|
|
|
|
#else
|
|
|
|
// unfortunately, mingw-W64 is somewhat inconsistent...
|
|
|
|
#define wxSeek _lseeki64
|
|
|
|
#define wxLseek _lseeki64
|
|
|
|
#define wxTell _telli64
|
|
|
|
#endif
|
2006-10-23 16:39:09 -04:00
|
|
|
#else // !wxHAS_HUGE_FILES
|
2006-10-29 08:55:52 -05:00
|
|
|
#define wxSeek wxPOSIX_IDENT(lseek)
|
|
|
|
#define wxLseek wxPOSIX_IDENT(lseek)
|
|
|
|
#define wxTell wxPOSIX_IDENT(tell)
|
2006-10-23 16:39:09 -04:00
|
|
|
#endif // wxHAS_HUGE_FILES/!wxHAS_HUGE_FILES
|
|
|
|
|
2014-05-16 09:01:06 -04:00
|
|
|
#if !defined(__BORLANDC__) || (__BORLANDC__ > 0x540)
|
|
|
|
// NB: this one is not POSIX and always has the underscore
|
|
|
|
#define wxFsync _commit
|
2006-10-23 16:39:09 -04:00
|
|
|
|
2014-05-16 09:01:06 -04:00
|
|
|
// could be already defined by configure (Cygwin)
|
|
|
|
#ifndef HAVE_FSYNC
|
|
|
|
#define HAVE_FSYNC
|
|
|
|
#endif
|
|
|
|
#endif // BORLANDC
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2006-10-29 08:55:52 -05:00
|
|
|
#define wxEof wxPOSIX_IDENT(eof)
|
|
|
|
|
|
|
|
// then the functions taking strings
|
2009-04-25 11:53:45 -04:00
|
|
|
|
|
|
|
// first the ANSI versions
|
|
|
|
#define wxCRT_OpenA wxPOSIX_IDENT(open)
|
|
|
|
#define wxCRT_AccessA wxPOSIX_IDENT(access)
|
2013-08-07 07:08:28 -04:00
|
|
|
#define wxCRT_ChmodA wxPOSIX_IDENT(chmod)
|
2009-04-25 11:53:45 -04:00
|
|
|
#define wxCRT_MkDirA wxPOSIX_IDENT(mkdir)
|
|
|
|
#define wxCRT_RmDirA wxPOSIX_IDENT(rmdir)
|
|
|
|
#ifdef wxHAS_HUGE_FILES
|
2011-10-17 18:26:13 -04:00
|
|
|
// MinGW-64 provides underscore-less versions of all file functions
|
|
|
|
// except for this one.
|
|
|
|
#ifdef __MINGW64__
|
|
|
|
#define wxCRT_StatA _stati64
|
|
|
|
#else
|
|
|
|
#define wxCRT_StatA wxPOSIX_IDENT(stati64)
|
|
|
|
#endif
|
2009-04-25 11:53:45 -04:00
|
|
|
#else
|
2014-05-15 19:56:58 -04:00
|
|
|
#define wxCRT_StatA wxPOSIX_IDENT(stat)
|
2009-04-25 11:53:45 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// then wide char ones
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
// special workaround for buggy wopen() in bcc 5.5
|
|
|
|
#if defined(__BORLANDC__) && \
|
|
|
|
(__BORLANDC__ >= 0x550 && __BORLANDC__ <= 0x551)
|
|
|
|
WXDLLIMPEXP_BASE int wxCRT_OpenW(const wxChar *pathname,
|
|
|
|
int flags, mode_t mode);
|
|
|
|
#else
|
|
|
|
#define wxCRT_OpenW _wopen
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define wxCRT_AccessW _waccess
|
2013-08-07 07:08:28 -04:00
|
|
|
#define wxCRT_ChmodW _wchmod
|
2009-04-25 11:53:45 -04:00
|
|
|
#define wxCRT_MkDirW _wmkdir
|
|
|
|
#define wxCRT_RmDirW _wrmdir
|
|
|
|
#ifdef wxHAS_HUGE_FILES
|
|
|
|
#define wxCRT_StatW _wstati64
|
|
|
|
#else
|
|
|
|
#define wxCRT_StatW _wstat
|
|
|
|
#endif
|
|
|
|
#endif // wxUSE_UNICODE
|
|
|
|
|
|
|
|
|
|
|
|
// finally the default char-type versions
|
2000-07-15 15:51:35 -04:00
|
|
|
#if wxUSE_UNICODE
|
2014-05-15 22:33:40 -04:00
|
|
|
#define wxCRT_Open wxCRT_OpenW
|
|
|
|
#define wxCRT_Access wxCRT_AccessW
|
|
|
|
#define wxCRT_Chmod wxCRT_ChmodW
|
|
|
|
#define wxCRT_MkDir wxCRT_MkDirW
|
|
|
|
#define wxCRT_RmDir wxCRT_RmDirW
|
|
|
|
#define wxCRT_Stat wxCRT_StatW
|
2000-07-15 15:51:35 -04:00
|
|
|
#else // !wxUSE_UNICODE
|
2009-04-25 11:53:45 -04:00
|
|
|
#define wxCRT_Open wxCRT_OpenA
|
|
|
|
#define wxCRT_Access wxCRT_AccessA
|
2013-08-07 07:08:28 -04:00
|
|
|
#define wxCRT_Chmod wxCRT_ChmodA
|
2009-04-25 11:53:45 -04:00
|
|
|
#define wxCRT_MkDir wxCRT_MkDirA
|
|
|
|
#define wxCRT_RmDir wxCRT_RmDirA
|
|
|
|
#define wxCRT_Stat wxCRT_StatA
|
2006-10-23 16:39:09 -04:00
|
|
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2009-04-25 11:53:45 -04:00
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// constants (unless already defined by the user code)
|
2006-10-29 08:55:52 -05:00
|
|
|
#ifdef wxHAS_UNDERSCORES_IN_POSIX_IDENTS
|
2004-10-07 20:26:20 -04:00
|
|
|
#ifndef O_RDONLY
|
|
|
|
#define O_RDONLY _O_RDONLY
|
|
|
|
#define O_WRONLY _O_WRONLY
|
|
|
|
#define O_RDWR _O_RDWR
|
|
|
|
#define O_EXCL _O_EXCL
|
|
|
|
#define O_CREAT _O_CREAT
|
|
|
|
#define O_BINARY _O_BINARY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef S_IFMT
|
|
|
|
#define S_IFMT _S_IFMT
|
|
|
|
#define S_IFDIR _S_IFDIR
|
|
|
|
#define S_IFREG _S_IFREG
|
|
|
|
#endif
|
2006-10-29 08:55:52 -05:00
|
|
|
#endif // wxHAS_UNDERSCORES_IN_POSIX_IDENTS
|
2004-09-25 18:44:19 -04:00
|
|
|
|
2006-10-24 08:08:05 -04:00
|
|
|
#ifdef wxHAS_HUGE_FILES
|
2009-12-22 16:22:59 -05:00
|
|
|
// wxFile is present and supports large files.
|
2006-10-23 08:51:00 -04:00
|
|
|
#if wxUSE_FILE
|
2006-10-23 17:46:13 -04:00
|
|
|
#define wxHAS_LARGE_FILES
|
2006-10-23 08:51:00 -04:00
|
|
|
#endif
|
2009-12-22 16:22:59 -05:00
|
|
|
// wxFFile is present and supports large files
|
|
|
|
#if wxUSE_FFILE && defined wxHAS_HUGE_STDIO_FILES
|
|
|
|
#define wxHAS_LARGE_FFILES
|
|
|
|
#endif
|
2006-10-23 08:51:00 -04:00
|
|
|
#endif
|
2006-10-23 16:39:09 -04:00
|
|
|
|
2009-12-22 16:22:59 -05:00
|
|
|
// private defines, undefine so that nobody gets tempted to use
|
2004-10-07 20:20:07 -04:00
|
|
|
#undef wxHAS_HUGE_FILES
|
2009-12-22 16:22:59 -05:00
|
|
|
#undef wxHAS_HUGE_STDIO_FILES
|
2006-10-23 16:39:09 -04:00
|
|
|
#else // Unix or Windows using unknown compiler, assume POSIX supported
|
2004-09-25 18:44:19 -04:00
|
|
|
typedef off_t wxFileOffset;
|
2009-05-30 13:15:36 -04:00
|
|
|
#ifdef HAVE_LARGEFILE_SUPPORT
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
2004-10-14 20:23:32 -04:00
|
|
|
wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
|
|
|
|
BadFileSizeType );
|
2006-10-23 08:51:00 -04:00
|
|
|
// wxFile is present and supports large files
|
2009-05-30 13:15:36 -04:00
|
|
|
#if wxUSE_FILE
|
2006-10-23 17:46:13 -04:00
|
|
|
#define wxHAS_LARGE_FILES
|
2006-10-23 08:51:00 -04:00
|
|
|
#endif
|
|
|
|
// wxFFile is present and supports large files
|
2009-05-30 13:15:36 -04:00
|
|
|
#if wxUSE_FFILE && (SIZEOF_LONG == 8 || defined HAVE_FSEEKO)
|
2006-10-23 17:46:13 -04:00
|
|
|
#define wxHAS_LARGE_FFILES
|
2006-10-23 08:51:00 -04:00
|
|
|
#endif
|
2009-12-22 16:22:59 -05:00
|
|
|
#ifdef HAVE_FSEEKO
|
|
|
|
#define wxFseek fseeko
|
|
|
|
#define wxFtell ftello
|
|
|
|
#endif
|
2004-09-25 18:44:19 -04:00
|
|
|
#else
|
2009-07-23 16:30:22 -04:00
|
|
|
#define wxFileOffsetFmtSpec wxT("")
|
2004-09-25 18:44:19 -04:00
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
// functions
|
|
|
|
#define wxClose close
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxRead ::read
|
|
|
|
#define wxWrite ::write
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxLseek lseek
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxSeek lseek
|
2005-08-03 21:05:26 -04:00
|
|
|
#define wxFsync fsync
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxEof eof
|
2007-06-10 13:14:14 -04:00
|
|
|
#define wxCRT_MkDir mkdir
|
|
|
|
#define wxCRT_RmDir rmdir
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
#define wxTell(fd) lseek(fd, 0, SEEK_CUR)
|
|
|
|
|
|
|
|
#define wxStructStat struct stat
|
2004-09-14 08:08:28 -04:00
|
|
|
|
2007-06-10 13:14:14 -04:00
|
|
|
#define wxCRT_Open open
|
|
|
|
#define wxCRT_Stat stat
|
|
|
|
#define wxCRT_Lstat lstat
|
|
|
|
#define wxCRT_Access access
|
2013-08-07 07:08:28 -04:00
|
|
|
#define wxCRT_Chmod chmod
|
2006-10-21 10:45:40 -04:00
|
|
|
|
2006-10-23 16:39:09 -04:00
|
|
|
#define wxHAS_NATIVE_LSTAT
|
2004-09-27 10:33:51 -04:00
|
|
|
#endif // platforms
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2007-06-10 13:14:14 -04:00
|
|
|
// if the platform doesn't have symlinks, define wxCRT_Lstat to be the same as
|
|
|
|
// wxCRT_Stat to avoid #ifdefs in the code using it
|
|
|
|
#ifndef wxHAS_NATIVE_LSTAT
|
|
|
|
#define wxCRT_Lstat wxCRT_Stat
|
|
|
|
#endif
|
|
|
|
|
2009-12-22 16:22:59 -05:00
|
|
|
// define wxFseek/wxFtell to large file versions if available (done above) or
|
|
|
|
// to fseek/ftell if not, to save ifdefs in using code
|
|
|
|
#ifndef wxFseek
|
|
|
|
#define wxFseek fseek
|
|
|
|
#endif
|
|
|
|
#ifndef wxFtell
|
|
|
|
#define wxFtell ftell
|
|
|
|
#endif
|
|
|
|
|
2007-06-10 13:14:14 -04:00
|
|
|
inline int wxAccess(const wxString& path, mode_t mode)
|
|
|
|
{ return wxCRT_Access(path.fn_str(), mode); }
|
2013-08-07 07:08:28 -04:00
|
|
|
inline int wxChmod(const wxString& path, mode_t mode)
|
|
|
|
{ return wxCRT_Chmod(path.fn_str(), mode); }
|
2007-06-10 13:14:14 -04:00
|
|
|
inline int wxOpen(const wxString& path, int flags, mode_t mode)
|
|
|
|
{ return wxCRT_Open(path.fn_str(), flags, mode); }
|
2007-07-27 12:34:24 -04:00
|
|
|
|
|
|
|
// FIXME-CE: provide our own implementations of the missing CRT functions
|
|
|
|
#ifndef __WXWINCE__
|
|
|
|
inline int wxStat(const wxString& path, wxStructStat *buf)
|
|
|
|
{ return wxCRT_Stat(path.fn_str(), buf); }
|
|
|
|
inline int wxLstat(const wxString& path, wxStructStat *buf)
|
|
|
|
{ return wxCRT_Lstat(path.fn_str(), buf); }
|
2007-06-10 13:14:14 -04:00
|
|
|
inline int wxRmDir(const wxString& path)
|
|
|
|
{ return wxCRT_RmDir(path.fn_str()); }
|
2014-05-15 19:56:58 -04:00
|
|
|
#if (defined(__WINDOWS__) && !defined(__CYGWIN__))
|
2007-06-10 13:14:14 -04:00
|
|
|
inline int wxMkDir(const wxString& path, mode_t WXUNUSED(mode) = 0)
|
|
|
|
{ return wxCRT_MkDir(path.fn_str()); }
|
|
|
|
#else
|
|
|
|
inline int wxMkDir(const wxString& path, mode_t mode)
|
|
|
|
{ return wxCRT_MkDir(path.fn_str(), mode); }
|
|
|
|
#endif
|
2007-07-27 12:34:24 -04:00
|
|
|
#endif // !__WXWINCE__
|
2007-06-10 13:14:14 -04:00
|
|
|
|
2006-10-23 08:51:00 -04:00
|
|
|
#ifdef O_BINARY
|
|
|
|
#define wxO_BINARY O_BINARY
|
|
|
|
#else
|
|
|
|
#define wxO_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
2004-11-10 16:02:58 -05:00
|
|
|
const int wxInvalidOffset = -1;
|
2000-07-15 15:51:35 -04:00
|
|
|
|
1998-07-14 18:15:29 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// functions
|
|
|
|
// ----------------------------------------------------------------------------
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// does the path exist? (may have or not '/' or '\\' at the end)
|
2007-03-02 07:44:52 -05:00
|
|
|
WXDLLIMPEXP_BASE bool wxDirExists(const wxString& pathName);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Get filename
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxFileNameFromPath(wxChar *path);
|
|
|
|
WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Get directory
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-01-06 20:29:54 -05:00
|
|
|
// all deprecated functions below are deprecated in favour of wxFileName's methods
|
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-01-06 20:29:54 -05:00
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(char *s) );
|
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxDos2UnixFilename(wchar_t *s) );
|
|
|
|
|
2009-01-12 06:55:44 -05:00
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY(
|
|
|
|
WXDLLIMPEXP_BASE void wxUnix2DosFilename(char *s) );
|
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY(
|
|
|
|
WXDLLIMPEXP_BASE void wxUnix2DosFilename(wchar_t *s) );
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Strip the extension, in situ
|
2009-03-26 11:55:01 -04:00
|
|
|
// Deprecated in favour of wxFileName::StripExtension() but notice that their
|
|
|
|
// behaviour is slightly different, see the manual
|
2009-01-06 20:29:54 -05:00
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(char *buffer) );
|
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wchar_t *buffer) );
|
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer) );
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2001-12-01 12:18:11 -05:00
|
|
|
// Get a temporary filename
|
2009-01-19 08:55:27 -05:00
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = NULL) );
|
2009-01-10 11:04:36 -05:00
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf) );
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Expand file name (~/ and ${OPENWINHOME}/ stuff)
|
2009-01-10 11:04:36 -05:00
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxExpandPath(char *dest, const wxString& path) );
|
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxExpandPath(wchar_t *dest, const wxString& path) );
|
2009-01-06 20:29:54 -05:00
|
|
|
// DEPRECATED: use wxFileName::Normalize(wxPATH_NORM_ENV_VARS)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Contract w.r.t environment (</usr/openwin/lib, OPENWHOME> -> ${OPENWINHOME}/lib)
|
|
|
|
// and make (if under the home tree) relative to home
|
|
|
|
// [caller must copy-- volatile]
|
2009-01-06 20:29:54 -05:00
|
|
|
wxDEPRECATED(
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename,
|
2001-12-01 12:18:11 -05:00
|
|
|
const wxString& envname = wxEmptyString,
|
2009-01-06 20:29:54 -05:00
|
|
|
const wxString& user = wxEmptyString) );
|
|
|
|
// DEPRECATED: use wxFileName::ReplaceEnvVariable and wxFileName::ReplaceHomeDir
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Destructive removal of /./ and /../ stuff
|
2009-01-10 11:04:36 -05:00
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE char* wxRealPath(char *path) );
|
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wchar_t* wxRealPath(wchar_t *path) );
|
|
|
|
wxDEPRECATED_BUT_USED_INTERNALLY( WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path) );
|
2009-01-06 20:29:54 -05:00
|
|
|
// DEPRECATED: use wxFileName::Normalize instead
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Allocate a copy of the full absolute path
|
2009-01-06 20:29:54 -05:00
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path) );
|
|
|
|
// DEPRECATED: use wxFileName::MakeAbsolute instead
|
|
|
|
#endif
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Get first file name matching given wild card.
|
|
|
|
// Flags are reserved for future use.
|
|
|
|
#define wxFILE 1
|
|
|
|
#define wxDIR 2
|
2007-06-10 13:14:14 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxString& spec, int flags = wxFILE);
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxFindNextFile();
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Does the pattern contain wildcards?
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxIsWild(const wxString& pattern);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Does the pattern match the text (usually a filename)?
|
2004-09-14 08:08:28 -04:00
|
|
|
// If dot_special is true, doesn't match * against . (eliminating
|
1998-05-20 10:01:55 -04:00
|
|
|
// `hidden' dot files)
|
2004-09-14 08:08:28 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxMatchWild(const wxString& pattern, const wxString& text, bool dot_special = true);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Concatenate two files to form third
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Copy file1 to file2
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& file1, const wxString& file2,
|
2004-09-14 08:08:28 -04:00
|
|
|
bool overwrite = true);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Remove file
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Rename file
|
2006-04-16 17:14:00 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite = true);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Get current working directory.
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxGetCwd();
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Set working directory
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Make directory
|
2010-02-10 06:38:41 -05:00
|
|
|
WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = wxS_DIR_DEFAULT);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Remove directory. Flags reserved for future use.
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2005-02-11 07:39:03 -05:00
|
|
|
// Return the type of an open file
|
2005-02-12 16:53:51 -05:00
|
|
|
WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd);
|
2005-03-05 18:24:17 -05:00
|
|
|
WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp);
|
2005-02-11 07:39:03 -05:00
|
|
|
|
2006-10-05 13:28:31 -04:00
|
|
|
// permissions; these functions work both on files and directories:
|
|
|
|
WXDLLIMPEXP_BASE bool wxIsWritable(const wxString &path);
|
|
|
|
WXDLLIMPEXP_BASE bool wxIsReadable(const wxString &path);
|
|
|
|
WXDLLIMPEXP_BASE bool wxIsExecutable(const wxString &path);
|
|
|
|
|
2001-11-30 18:38:06 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:01:55 -04:00
|
|
|
// separators in file names
|
2001-11-30 18:38:06 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// between file name and extension
|
1999-10-08 10:35:56 -04:00
|
|
|
#define wxFILE_SEP_EXT wxT('.')
|
2001-11-30 18:38:06 -05:00
|
|
|
|
|
|
|
// between drive/volume name and the path
|
1999-10-08 10:35:56 -04:00
|
|
|
#define wxFILE_SEP_DSK wxT(':')
|
2001-11-30 18:38:06 -05:00
|
|
|
|
|
|
|
// between the path components
|
1999-10-08 10:35:56 -04:00
|
|
|
#define wxFILE_SEP_PATH_DOS wxT('\\')
|
|
|
|
#define wxFILE_SEP_PATH_UNIX wxT('/')
|
2000-12-30 19:23:09 -05:00
|
|
|
#define wxFILE_SEP_PATH_MAC wxT(':')
|
2001-11-30 18:38:06 -05:00
|
|
|
#define wxFILE_SEP_PATH_VMS wxT('.') // VMS also uses '[' and ']'
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// separator in the path list (as in PATH environment variable)
|
2001-02-15 16:51:14 -05:00
|
|
|
// there is no PATH variable in Classic Mac OS so just use the
|
|
|
|
// semicolon (it must be different from the file name separator)
|
1998-05-20 10:01:55 -04:00
|
|
|
// NB: these are strings and not characters on purpose!
|
1999-10-08 10:35:56 -04:00
|
|
|
#define wxPATH_SEP_DOS wxT(";")
|
|
|
|
#define wxPATH_SEP_UNIX wxT(":")
|
2001-02-15 16:51:14 -05:00
|
|
|
#define wxPATH_SEP_MAC wxT(";")
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// platform independent versions
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__UNIX__)
|
2004-07-25 07:33:34 -04:00
|
|
|
// CYGWIN also uses UNIX settings
|
1999-02-09 12:04:29 -05:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
|
|
|
|
#define wxPATH_SEP wxPATH_SEP_UNIX
|
2000-12-30 19:23:09 -05:00
|
|
|
#elif defined(__MAC__)
|
2001-05-24 17:22:04 -04:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
|
2001-10-14 04:21:22 -04:00
|
|
|
#define wxPATH_SEP wxPATH_SEP_MAC
|
1999-07-27 23:38:12 -04:00
|
|
|
#else // Windows and OS/2
|
1999-02-09 12:04:29 -05:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
|
|
|
#define wxPATH_SEP wxPATH_SEP_DOS
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif // Unix/Windows
|
|
|
|
|
1998-07-14 17:55:17 -04:00
|
|
|
// this is useful for wxString::IsSameAs(): to compare two file names use
|
|
|
|
// filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE)
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__UNIX__) && !defined(__DARWIN__)
|
2004-09-14 08:08:28 -04:00
|
|
|
#define wxARE_FILENAMES_CASE_SENSITIVE true
|
2001-10-14 04:21:22 -04:00
|
|
|
#else // Windows, Mac OS and OS/2
|
2004-09-14 08:08:28 -04:00
|
|
|
#define wxARE_FILENAMES_CASE_SENSITIVE false
|
1998-07-14 17:55:17 -04:00
|
|
|
#endif // Unix/Windows
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
// is the char a path separator?
|
1999-04-12 18:20:19 -04:00
|
|
|
inline bool wxIsPathSeparator(wxChar c)
|
2002-01-03 20:39:22 -05:00
|
|
|
{
|
|
|
|
// under DOS/Windows we should understand both Unix and DOS file separators
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__UNIX__) || defined(__MAC__)
|
2002-01-03 20:39:22 -05:00
|
|
|
return c == wxFILE_SEP_PATH;
|
|
|
|
#else
|
|
|
|
return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX;
|
|
|
|
#endif
|
|
|
|
}
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// does the string ends with path separator?
|
2007-06-10 13:14:14 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxString& filename);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2009-01-06 20:29:54 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
1998-07-14 17:55:17 -04:00
|
|
|
// split the full path into path (including drive for DOS), name and extension
|
|
|
|
// (understands both '/' and '\\')
|
2009-05-09 08:41:31 -04:00
|
|
|
// Deprecated in favour of wxFileName::SplitPath
|
2009-01-06 20:29:54 -05:00
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE void wxSplitPath(const wxString& fileName,
|
|
|
|
wxString *pstrPath,
|
|
|
|
wxString *pstrName,
|
|
|
|
wxString *pstrExt) );
|
|
|
|
#endif
|
1998-07-14 17:55:17 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
// find a file in a list of directories, returns false if not found
|
2007-06-10 13:14:14 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxString& szPath, const wxString& szFile);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-02-06 08:32:46 -05:00
|
|
|
// Get the OS directory if appropriate (such as the Windows directory).
|
|
|
|
// On non-Windows platform, probably just return the empty string.
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxGetOSDirectory();
|
1999-02-06 08:32:46 -05:00
|
|
|
|
2006-07-31 08:03:22 -04:00
|
|
|
#if wxUSE_DATETIME
|
|
|
|
|
2000-01-18 20:00:25 -05:00
|
|
|
// Get file modification time
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE time_t wxFileModificationTime(const wxString& filename);
|
2000-01-18 20:00:25 -05:00
|
|
|
|
2006-07-31 08:03:22 -04:00
|
|
|
#endif // wxUSE_DATETIME
|
|
|
|
|
2004-06-15 11:25:33 -04:00
|
|
|
// Parses the wildCard, returning the number of filters.
|
|
|
|
// Returns 0 if none or if there's a problem,
|
|
|
|
// The arrays will contain an equal number of items found before the error.
|
|
|
|
// wildCard is in the form:
|
|
|
|
// "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
|
2004-06-22 12:58:27 -04:00
|
|
|
WXDLLIMPEXP_BASE int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
|
2004-06-15 11:25:33 -04:00
|
|
|
|
1998-07-14 18:15:29 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2004-10-03 18:12:58 -04:00
|
|
|
#ifdef __UNIX__
|
|
|
|
|
|
|
|
// set umask to the given value in ctor and reset it to the old one in dtor
|
|
|
|
class WXDLLIMPEXP_BASE wxUmaskChanger
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// change the umask to the given one if it is not -1: this allows to write
|
|
|
|
// the same code whether you really want to change umask or not, as is in
|
|
|
|
// wxFileConfig::Flush() for example
|
|
|
|
wxUmaskChanger(int umaskNew)
|
|
|
|
{
|
2004-10-04 04:26:55 -04:00
|
|
|
m_umaskOld = umaskNew == -1 ? -1 : (int)umask((mode_t)umaskNew);
|
2004-10-03 18:12:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
~wxUmaskChanger()
|
|
|
|
{
|
|
|
|
if ( m_umaskOld != -1 )
|
|
|
|
umask((mode_t)m_umaskOld);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_umaskOld;
|
|
|
|
};
|
|
|
|
|
|
|
|
// this macro expands to an "anonymous" wxUmaskChanger object under Unix and
|
|
|
|
// nothing elsewhere
|
|
|
|
#define wxCHANGE_UMASK(m) wxUmaskChanger wxMAKE_UNIQUE_NAME(umaskChanger_)(m)
|
|
|
|
|
|
|
|
#else // !__UNIX__
|
|
|
|
|
|
|
|
#define wxCHANGE_UMASK(m)
|
|
|
|
|
|
|
|
#endif // __UNIX__/!__UNIX__
|
|
|
|
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
// Path searching
|
2006-07-24 20:16:55 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxPathList : public wxArrayString
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-29 17:21:32 -05:00
|
|
|
public:
|
2006-07-24 20:16:55 -04:00
|
|
|
wxPathList() {}
|
|
|
|
wxPathList(const wxArrayString &arr)
|
|
|
|
{ Add(arr); }
|
|
|
|
|
1999-02-09 12:04:29 -05:00
|
|
|
// Adds all paths in environment variable
|
|
|
|
void AddEnvList(const wxString& envVariable);
|
1999-01-26 06:51:12 -05:00
|
|
|
|
2006-07-24 20:16:55 -04:00
|
|
|
// Adds given path to this list
|
2006-10-27 13:59:32 -04:00
|
|
|
bool Add(const wxString& path);
|
2006-07-24 20:16:55 -04:00
|
|
|
void Add(const wxArrayString &paths);
|
|
|
|
|
1999-02-09 12:04:29 -05:00
|
|
|
// Find the first full path for which the file exists
|
2006-07-24 20:16:55 -04:00
|
|
|
wxString FindValidPath(const wxString& filename) const;
|
|
|
|
|
1999-02-09 12:04:29 -05:00
|
|
|
// Find the first full path for which the file exists; ensure it's an
|
|
|
|
// absolute path that gets returned.
|
2006-07-24 20:16:55 -04:00
|
|
|
wxString FindAbsoluteValidPath(const wxString& filename) const;
|
|
|
|
|
1999-02-09 12:04:29 -05:00
|
|
|
// Given full path and filename, add path to list
|
2006-10-27 13:59:32 -04:00
|
|
|
bool EnsureFileAccessible(const wxString& path);
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2006-07-24 20:16:55 -04:00
|
|
|
#endif // _WX_FILEFN_H_
|