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
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// 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
|
|
|
|
2004-09-25 18:44:19 -04:00
|
|
|
#ifdef __WXWINCE__
|
|
|
|
// Nothing
|
|
|
|
#elif !defined(__MWERKS__)
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#else
|
|
|
|
#ifdef __MACH__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <utime.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#else
|
|
|
|
#include <stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unix.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __OS2__
|
|
|
|
// need to check for __OS2__ first since currently both
|
|
|
|
// __OS2__ and __UNIX__ are defined.
|
|
|
|
#include <process.h>
|
|
|
|
#include "wx/os2/private.h"
|
2005-07-21 13:08:28 -04:00
|
|
|
#ifdef __WATCOMC__
|
|
|
|
#include <direct.h>
|
|
|
|
#endif
|
2004-09-25 18:44:19 -04:00
|
|
|
#include <io.h>
|
|
|
|
#ifdef __EMX__
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#elif defined(__UNIX__)
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
2005-05-19 13:03:10 -04:00
|
|
|
#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) && !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 __WATCOMC__
|
|
|
|
#include <direct.h>
|
|
|
|
#include <dos.h>
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
#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
|
|
|
|
|
|
|
|
#ifdef __SALFORDC__
|
|
|
|
#include <dir.h>
|
|
|
|
#include <unix.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __WXWINCE__
|
|
|
|
#include <fcntl.h> // O_RDONLY &c
|
|
|
|
#endif
|
1998-07-14 18:15:29 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
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
|
|
|
|
2004-09-27 17:08:54 -04:00
|
|
|
#if (defined(__VISUALC__) && !defined(__WXWINCE__)) || ( defined(__MWERKS__) && defined( __INTEL__) )
|
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;
|
2003-03-28 14:18:51 -05:00
|
|
|
#elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__)
|
1999-02-11 11:56:43 -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
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
#define wxFileOffsetFmtSpec _("I64")
|
|
|
|
int wxOpen(const wxChar *filename, int oflag, int WXUNUSED(pmode));
|
|
|
|
int wxAccess(const wxChar *name, int WXUNUSED(how));
|
|
|
|
int wxClose(int fd);
|
|
|
|
int wxFsync(int WXUNUSED(fd));
|
|
|
|
int wxRead(int fd, void *buf, unsigned int count);
|
|
|
|
int wxWrite(int fd, const void *buf, unsigned int count);
|
|
|
|
int wxEof(int fd);
|
|
|
|
wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin);
|
|
|
|
#define wxLSeek wxSeek
|
|
|
|
wxFileOffset wxTell(int fd);
|
2005-03-17 12:46:32 -05:00
|
|
|
|
2005-01-07 13:47:29 -05:00
|
|
|
// always Unicode under WinCE
|
|
|
|
#define wxMkDir _wmkdir
|
|
|
|
#define wxRmDir _wrmdir
|
|
|
|
#define wxStat _wstat
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStructStat struct _stat
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// Microsoft compiler loves underscores, feed them to it
|
2004-09-25 18:44:19 -04:00
|
|
|
#elif defined( __VISUALC__ ) \
|
2003-01-07 08:49:08 -05:00
|
|
|
|| ( defined(__MINGW32__) && !defined(__WINE__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
|
2003-09-30 08:41:46 -04:00
|
|
|
|| ( defined(__MWERKS__) && defined(__WXMSW__) ) \
|
2004-02-07 10:07:08 -05:00
|
|
|
|| ( defined(__DMC__) && defined(__WXMSW__) ) \
|
2003-09-30 08:41:46 -04:00
|
|
|
|| ( defined(__WATCOMC__) && defined(__WXMSW__) )
|
2004-09-25 18:44:19 -04:00
|
|
|
|
2004-09-26 16:28:58 -04:00
|
|
|
// detect compilers which have support for huge files (currently only
|
|
|
|
// Digital Mars doesn't)
|
2004-12-20 07:44:22 -05:00
|
|
|
#ifndef __WXPALMOS__
|
2004-09-26 09:18:46 -04:00
|
|
|
#include "wx/msw/private.h"
|
2004-10-19 09:40:30 -04:00
|
|
|
#endif
|
2004-09-26 09:18:46 -04:00
|
|
|
|
2004-10-07 20:20:07 -04:00
|
|
|
#undef wxHAS_HUGE_FILES
|
2004-09-26 16:28:58 -04:00
|
|
|
#if defined(__MINGW32__)
|
2004-10-07 20:20:07 -04:00
|
|
|
#define wxHAS_HUGE_FILES 1
|
2004-10-03 09:36:46 -04:00
|
|
|
#elif defined(__MWERKS__)
|
2004-10-07 20:20:07 -04:00
|
|
|
#define wxHAS_HUGE_FILES 0
|
2004-09-26 16:28:58 -04:00
|
|
|
#elif defined(__DMC__)
|
2004-10-07 20:20:07 -04:00
|
|
|
#define wxHAS_HUGE_FILES 0
|
2004-09-26 16:28:58 -04:00
|
|
|
#elif ((_INTEGRAL_MAX_BITS >= 64) || defined(_LARGE_FILES))
|
2004-10-07 20:20:07 -04:00
|
|
|
#define wxHAS_HUGE_FILES 1
|
2004-09-25 18:44:19 -04:00
|
|
|
#else
|
2004-10-07 20:20:07 -04:00
|
|
|
#define wxHAS_HUGE_FILES 0
|
2004-09-25 18:44:19 -04:00
|
|
|
#endif
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// functions
|
2004-09-25 18:44:19 -04:00
|
|
|
#if defined(__BORLANDC__) || defined(__WATCOMC__)
|
|
|
|
#define _tell tell
|
|
|
|
#endif
|
|
|
|
|
2004-10-07 20:20:07 -04:00
|
|
|
#if 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
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxClose _close
|
2004-09-25 18:44:19 -04:00
|
|
|
|
|
|
|
#if defined(__MWERKS__)
|
|
|
|
#if __MSL__ >= 0x6000
|
2004-10-03 09:36:46 -04:00
|
|
|
#define wxRead(fd, buf, nCount) _read(fd, (void *)buf, nCount)
|
|
|
|
#define wxWrite(fd, buf, nCount) _write(fd, (void *)buf, nCount)
|
2004-09-25 18:44:19 -04:00
|
|
|
#else
|
2004-10-03 09:36:46 -04:00
|
|
|
#define wxRead(fd, buf, nCount)\
|
|
|
|
_read(fd, (const char *)buf, nCount)
|
|
|
|
#define wxWrite(fd, buf, nCount)\
|
|
|
|
_write(fd, (const char *)buf, nCount)
|
2004-09-25 18:44:19 -04:00
|
|
|
#endif
|
|
|
|
#else
|
2004-11-10 16:02:58 -05:00
|
|
|
#if defined(__DMC__) || defined(__WATCOMC__)
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxRead ::read
|
|
|
|
#define wxWrite ::write
|
|
|
|
#else
|
|
|
|
#define wxRead _read
|
|
|
|
#define wxWrite _write
|
|
|
|
#endif
|
|
|
|
#endif
|
2004-10-07 20:20:07 -04:00
|
|
|
#if wxHAS_HUGE_FILES
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxSeek _lseeki64
|
|
|
|
#define wxLseek _lseeki64
|
|
|
|
#define wxTell _telli64
|
|
|
|
#else
|
|
|
|
#define wxSeek _lseek
|
|
|
|
#define wxLseek _lseek
|
|
|
|
#define wxTell _tell
|
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxFsync _commit
|
2004-09-27 13:27:41 -04:00
|
|
|
#if defined(__WATCOMC__)
|
|
|
|
#define wxEof ::eof
|
|
|
|
#else
|
|
|
|
#define wxEof _eof
|
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
#if wxUSE_UNICODE
|
2001-12-30 19:45:29 -05:00
|
|
|
#if wxUSE_UNICODE_MSLU
|
2003-04-28 17:09:58 -04:00
|
|
|
#define wxOpen wxMSLU__wopen
|
2004-09-14 08:08:28 -04:00
|
|
|
|
2002-02-17 18:29:25 -05:00
|
|
|
#define wxAccess wxMSLU__waccess
|
|
|
|
#define wxMkDir wxMSLU__wmkdir
|
|
|
|
#define wxRmDir wxMSLU__wrmdir
|
2004-10-07 20:20:07 -04:00
|
|
|
#if wxHAS_HUGE_FILES
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStat wxMSLU__wstati64
|
|
|
|
#else
|
|
|
|
#define wxStat wxMSLU__wstat
|
|
|
|
#endif
|
2001-12-30 19:45:29 -05:00
|
|
|
#else
|
|
|
|
#define wxOpen _wopen
|
2002-02-17 18:29:25 -05:00
|
|
|
#define wxAccess _waccess
|
|
|
|
#define wxMkDir _wmkdir
|
|
|
|
#define wxRmDir _wrmdir
|
2004-10-07 20:20:07 -04:00
|
|
|
#if wxHAS_HUGE_FILES
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStat _wstati64
|
|
|
|
#else
|
|
|
|
#define wxStat _wstat
|
|
|
|
#endif
|
2001-12-30 19:45:29 -05:00
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
#else // !wxUSE_UNICODE
|
2004-09-25 18:44:19 -04:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#define wxOpen open
|
|
|
|
#else
|
|
|
|
#define wxOpen _open
|
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxAccess _access
|
|
|
|
#define wxMkDir _mkdir
|
2004-09-25 18:44:19 -04:00
|
|
|
#ifdef __WATCOMC__
|
|
|
|
#define wxRmDir rmdir
|
|
|
|
#else
|
|
|
|
#define wxRmDir _rmdir
|
|
|
|
#endif
|
2004-10-07 20:20:07 -04:00
|
|
|
#if wxHAS_HUGE_FILES
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStat _stati64
|
|
|
|
#else
|
|
|
|
#define wxStat _stat
|
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
#endif
|
|
|
|
|
2005-11-09 16:04:54 -05:00
|
|
|
// Types: Notice that Watcom is the only compiler to have a wide char
|
|
|
|
// version of struct stat as well as a wide char stat function variant.
|
|
|
|
// This was droped since OW 1.4 "for consistency across platforms".
|
2004-10-07 20:20:07 -04:00
|
|
|
#if wxHAS_HUGE_FILES
|
2005-11-10 11:16:05 -05:00
|
|
|
#if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4)
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStructStat struct _wstati64
|
|
|
|
#else
|
|
|
|
#define wxStructStat struct _stati64
|
|
|
|
#endif
|
|
|
|
#else
|
2005-11-10 11:16:05 -05:00
|
|
|
#if wxUSE_UNICODE && wxONLY_WATCOM_EARLIER_THAN(1,4)
|
2004-09-25 18:44:19 -04:00
|
|
|
#define wxStructStat struct _wstat
|
|
|
|
#else
|
|
|
|
#define wxStructStat struct _stat
|
|
|
|
#endif
|
|
|
|
#endif
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
// constants (unless already defined by the user code)
|
2004-12-20 07:44:22 -05:00
|
|
|
#if !defined(__BORLANDC__) && !defined(__WATCOMC__) && !defined(__WXPALMOS__)
|
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
|
|
|
|
#endif
|
2004-09-25 18:44:19 -04:00
|
|
|
|
|
|
|
// It's a private define, undefine it so nobody gets tempted to use it
|
2004-10-07 20:20:07 -04:00
|
|
|
#undef wxHAS_HUGE_FILES
|
2004-09-27 10:33:51 -04:00
|
|
|
#else // Unix platforms using configure
|
2004-09-25 18:44:19 -04:00
|
|
|
typedef off_t wxFileOffset;
|
|
|
|
#ifdef _LARGE_FILES
|
|
|
|
#define wxFileOffsetFmtSpec wxLongLongFmtSpec
|
2004-10-14 20:23:32 -04:00
|
|
|
wxCOMPILE_TIME_ASSERT( sizeof(off_t) == sizeof(wxLongLong_t),
|
|
|
|
BadFileSizeType );
|
2004-09-25 18:44:19 -04:00
|
|
|
#else
|
|
|
|
#define wxFileOffsetFmtSpec _T("")
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define wxMkDir mkdir
|
|
|
|
#define wxRmDir rmdir
|
|
|
|
|
|
|
|
#define wxTell(fd) lseek(fd, 0, SEEK_CUR)
|
|
|
|
|
|
|
|
#define wxStructStat struct stat
|
2004-09-14 08:08:28 -04:00
|
|
|
|
2004-09-25 18:44:19 -04:00
|
|
|
#if wxUSE_UNICODE
|
|
|
|
#define wxNEED_WX_UNISTD_H
|
|
|
|
#if defined(__DMC__)
|
|
|
|
typedef unsigned long mode_t;
|
|
|
|
#endif
|
|
|
|
WXDLLIMPEXP_BASE int wxStat( const wxChar *file_name, wxStructStat *buf );
|
|
|
|
WXDLLIMPEXP_BASE int wxAccess( const wxChar *pathname, int mode );
|
|
|
|
WXDLLIMPEXP_BASE int wxOpen( const wxChar *pathname, int flags, mode_t mode );
|
|
|
|
#else
|
|
|
|
#define wxOpen open
|
|
|
|
#define wxStat stat
|
|
|
|
#define wxAccess access
|
|
|
|
#endif
|
2004-09-27 10:33:51 -04:00
|
|
|
#endif // platforms
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2004-09-27 10:33:51 -04:00
|
|
|
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
|
|
|
//
|
|
|
|
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
|
|
|
// in headers included by more than one primary source
|
|
|
|
//
|
2004-11-10 16:02:58 -05:00
|
|
|
extern const int wxInvalidOffset;
|
2004-09-27 10:33:51 -04:00
|
|
|
#else
|
2004-11-10 16:02:58 -05:00
|
|
|
const int wxInvalidOffset = -1;
|
2004-09-27 10:33:51 -04:00
|
|
|
#endif
|
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)
|
2005-04-05 12:10:48 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxDirExists(const wxChar *pszPathName);
|
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
|
|
|
|
|
|
|
// wxString version
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE void wxDos2UnixFilename(wxChar *s);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE void wxUnix2DosFilename(wxChar *s);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Strip the extension, in situ
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE void wxStripExtension(wxChar *buffer);
|
|
|
|
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
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL);
|
|
|
|
WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Expand file name (~/ and ${OPENWINHOME}/ stuff)
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxExpandPath(wxChar *dest, const wxChar *path);
|
|
|
|
WXDLLIMPEXP_BASE bool wxExpandPath(wxString& dest, const wxChar *path);
|
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]
|
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,
|
|
|
|
const wxString& user = wxEmptyString);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Destructive removal of /./ and /../ stuff
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxRealPath(wxChar *path);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Allocate a copy of the full absolute path
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path);
|
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
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE);
|
|
|
|
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
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// Get current working directory.
|
2005-11-07 08:27:09 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
1998-05-20 10:01:55 -04:00
|
|
|
// If buf is NULL, allocates space using new, else
|
|
|
|
// copies into buf.
|
|
|
|
// IMPORTANT NOTE getcwd is know not to work under some releases
|
|
|
|
// of Win32s 1.3, according to MS release notes!
|
2005-11-07 08:27:09 -05:00
|
|
|
wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000) );
|
1999-02-09 12:04:29 -05:00
|
|
|
// new and preferred version of wxGetWorkingDirectory
|
|
|
|
// NB: can't have the same name because of overloading ambiguity
|
2005-11-07 08:27:09 -05:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2_6
|
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
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777);
|
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
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
// compatibility defines, don't use in new code
|
2005-04-05 12:10:48 -04:00
|
|
|
// consider removal droping 2.4 compatibility
|
|
|
|
// #if WXWIN_COMPATIBILITY_2_4
|
|
|
|
wxDEPRECATED( inline bool wxPathExists(const wxChar *pszPathName) );
|
|
|
|
inline bool wxPathExists(const wxChar *pszPathName)
|
|
|
|
{
|
|
|
|
return wxDirExists(pszPathName);
|
|
|
|
}
|
|
|
|
// #endif //WXWIN_COMPATIBILITY_2_4
|
2002-12-04 09:11:26 -05:00
|
|
|
|
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
|
2004-07-25 07:33:34 -04:00
|
|
|
#if defined(__UNIX__) && !defined(__OS2__)
|
|
|
|
// 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)
|
2003-11-23 17:09:14 -05:00
|
|
|
#if defined(__UNIX__) && !defined(__DARWIN__) && !defined(__OS2__)
|
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
|
2004-09-14 08:08:28 -04:00
|
|
|
#if ( defined(__UNIX__) && !defined(__OS2__) )|| 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?
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxChar *pszFileName);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1998-07-14 17:55:17 -04:00
|
|
|
// split the full path into path (including drive for DOS), name and extension
|
|
|
|
// (understands both '/' and '\\')
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE void wxSplitPath(const wxChar *pszFileName,
|
1998-07-14 17:55:17 -04:00
|
|
|
wxString *pstrPath,
|
|
|
|
wxString *pstrName,
|
|
|
|
wxString *pstrExt);
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
// find a file in a list of directories, returns false if not found
|
2003-07-01 21:59:24 -04:00
|
|
|
WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile);
|
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
|
|
|
|
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
|
|
|
|
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
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxPathList : public wxStringList
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-11-29 17:21:32 -05:00
|
|
|
public:
|
Added --use-stl to cnfigure, wxUSE_STL to setup0.h
Moved wx/datetime.inl contents to wx/datetime.h and removed
inline redefinition hack.
Implemented STL-like interface on top of wxList/wxArray, when wxUSE_STL=0.
Implemented wxList-like and wxArray interfaces on top of std::list and
std::vector, when wxUSE_STL=1.
Added arrstr.h, moved wxArrayString declaration there; string.h
#includes arrstr.h only if WXWIN_COMPATIBILITY_2_4 is enabled.
Added WX_CLEAR_HASH_MAP, WX_CLEAR_HASH_TABLE, WX_CLEAR_LIST macros,
to clear a wxHashMap, wxHashTable, wxList containing pointers: deletes
pointers and makes container zero-sized.
When wxUSE_STL=1, wxStringList works like a std::list<wxString>.
Made wxBase compile when wxUSE_STL=1.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21768 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-08 15:52:35 -04:00
|
|
|
// avoid GCC warning about virtual functions w/o virtual dtor
|
|
|
|
virtual ~wxPathList() {}
|
|
|
|
|
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
|
|
|
|
1998-11-29 17:21:32 -05:00
|
|
|
void Add(const wxString& path);
|
1999-02-09 12:04:29 -05:00
|
|
|
// Find the first full path for which the file exists
|
|
|
|
wxString FindValidPath(const wxString& filename);
|
|
|
|
// Find the first full path for which the file exists; ensure it's an
|
|
|
|
// absolute path that gets returned.
|
|
|
|
wxString FindAbsoluteValidPath(const wxString& filename);
|
|
|
|
// Given full path and filename, add path to list
|
|
|
|
void EnsureFileAccessible(const wxString& path);
|
2004-09-14 08:08:28 -04:00
|
|
|
// Returns true if the path is in the list
|
1998-11-29 17:21:32 -05:00
|
|
|
bool Member(const wxString& path);
|
|
|
|
|
|
|
|
private:
|
Added --use-stl to cnfigure, wxUSE_STL to setup0.h
Moved wx/datetime.inl contents to wx/datetime.h and removed
inline redefinition hack.
Implemented STL-like interface on top of wxList/wxArray, when wxUSE_STL=0.
Implemented wxList-like and wxArray interfaces on top of std::list and
std::vector, when wxUSE_STL=1.
Added arrstr.h, moved wxArrayString declaration there; string.h
#includes arrstr.h only if WXWIN_COMPATIBILITY_2_4 is enabled.
Added WX_CLEAR_HASH_MAP, WX_CLEAR_HASH_TABLE, WX_CLEAR_LIST macros,
to clear a wxHashMap, wxHashTable, wxList containing pointers: deletes
pointers and makes container zero-sized.
When wxUSE_STL=1, wxStringList works like a std::list<wxString>.
Made wxBase compile when wxUSE_STL=1.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21768 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-08 15:52:35 -04:00
|
|
|
// DECLARE_DYNAMIC_CLASS(wxPathList)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_FILEFN_H_
|