1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: filefn.h
|
|
|
|
// 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 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _FILEFN_H_
|
|
|
|
#define _FILEFN_H_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-02-09 17:04:29 +00:00
|
|
|
#pragma interface "filefn.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-20 22:52:21 +00:00
|
|
|
#include "wx/list.h"
|
1998-07-15 18:40:37 +00:00
|
|
|
|
2002-12-07 15:41:13 +00:00
|
|
|
#ifndef __WXWINCE__
|
2000-01-19 01:00:25 +00:00
|
|
|
#include <time.h>
|
2002-12-07 15:41:13 +00:00
|
|
|
#endif
|
2000-01-19 01:00:25 +00:00
|
|
|
|
1998-07-14 22:15:29 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2002-12-07 15:41:13 +00:00
|
|
|
#ifdef __WXWINCE__
|
|
|
|
typedef long off_t;
|
|
|
|
#else
|
|
|
|
|
1998-07-14 22:15:29 +00:00
|
|
|
// define off_t
|
2003-03-28 19:18:51 +00:00
|
|
|
#if !defined(__WXMAC__) || defined(__UNIX__) || defined(__MACH__)
|
1999-02-09 17:04:29 +00:00
|
|
|
#include <sys/types.h>
|
1999-01-01 16:22:21 +00:00
|
|
|
#else
|
1999-02-09 17:04:29 +00:00
|
|
|
typedef long off_t;
|
1999-01-01 16:22:21 +00:00
|
|
|
#endif
|
1998-07-14 22:15:29 +00:00
|
|
|
|
1999-02-11 16:56:43 +00:00
|
|
|
#if defined(__VISUALC__) || ( defined(__MWERKS__) && defined( __INTEL__) )
|
1999-02-03 16:48:12 +00:00
|
|
|
typedef _off_t off_t;
|
2003-05-02 11:21:03 +00:00
|
|
|
#elif defined(__SYMANTEC__)
|
1999-02-03 16:48:12 +00:00
|
|
|
typedef long off_t;
|
2003-03-28 19:18:51 +00:00
|
|
|
#elif defined(__MWERKS__) && !defined(__INTEL__) && !defined(__MACH__)
|
1999-02-11 16:56:43 +00:00
|
|
|
typedef long off_t;
|
1999-01-07 08:43:47 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-29 09:36:05 +00:00
|
|
|
#endif
|
|
|
|
|
2000-01-26 21:07:57 +00:00
|
|
|
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
|
|
|
//
|
2000-01-31 21:28:20 +00:00
|
|
|
// VisualAge C++ V4.0 cannot have any external linkage const decs
|
2000-01-26 21:07:57 +00:00
|
|
|
// in headers included by more than one primary source
|
|
|
|
//
|
2000-01-31 21:28:20 +00:00
|
|
|
extern const off_t wxInvalidOffset;
|
|
|
|
#else
|
1998-07-24 17:13:47 +00:00
|
|
|
const off_t wxInvalidOffset = (off_t)-1;
|
2000-01-26 21:07:57 +00:00
|
|
|
#endif
|
1998-07-24 17:13:47 +00:00
|
|
|
|
1999-02-09 17:04:29 +00:00
|
|
|
enum wxSeekMode
|
|
|
|
{
|
1998-07-14 22:15:29 +00:00
|
|
|
wxFromStart,
|
|
|
|
wxFromCurrent,
|
|
|
|
wxFromEnd
|
1999-02-09 17:04:29 +00:00
|
|
|
};
|
1998-07-14 22:15:29 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// declare our versions of low level file functions: some compilers prepend
|
|
|
|
// underscores to the usual names, some also have Unicode versions of them
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Microsoft compiler loves underscores, feed them to it
|
2001-11-27 20:44:22 +00:00
|
|
|
#if defined( __VISUALC__ ) \
|
2003-01-07 13:49:08 +00:00
|
|
|
|| ( defined(__MINGW32__) && !defined(__WINE__) && wxCHECK_W32API_VERSION( 0, 5 ) ) \
|
2003-09-30 12:41:46 +00:00
|
|
|
|| ( defined(__MWERKS__) && defined(__WXMSW__) ) \
|
2004-02-07 15:07:08 +00:00
|
|
|
|| ( defined(__DMC__) && defined(__WXMSW__) ) \
|
2003-09-30 12:41:46 +00:00
|
|
|
|| ( defined(__WATCOMC__) && defined(__WXMSW__) )
|
2000-07-15 19:51:35 +00:00
|
|
|
// functions
|
2003-09-30 12:41:46 +00:00
|
|
|
#if defined(__BORLANDC__) || defined(__WATCOMC__)
|
2003-04-28 20:58:29 +00:00
|
|
|
#define _tell tell
|
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxClose _close
|
|
|
|
#define wxRead _read
|
|
|
|
#define wxWrite _write
|
|
|
|
#define wxLseek _lseek
|
|
|
|
#define wxFsync _commit
|
|
|
|
#define wxEof _eof
|
|
|
|
|
|
|
|
#define wxTell _tell
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE
|
2001-12-31 00:45:29 +00:00
|
|
|
#if wxUSE_UNICODE_MSLU
|
2003-04-28 21:09:58 +00:00
|
|
|
#define wxOpen wxMSLU__wopen
|
|
|
|
|
2002-02-17 23:29:25 +00:00
|
|
|
#define wxAccess wxMSLU__waccess
|
|
|
|
#define wxMkDir wxMSLU__wmkdir
|
|
|
|
#define wxRmDir wxMSLU__wrmdir
|
|
|
|
#define wxStat wxMSLU__wstat
|
2001-12-31 00:45:29 +00:00
|
|
|
#else
|
|
|
|
#define wxOpen _wopen
|
2002-02-17 23:29:25 +00:00
|
|
|
#define wxAccess _waccess
|
|
|
|
#define wxMkDir _wmkdir
|
|
|
|
#define wxRmDir _wrmdir
|
|
|
|
#define wxStat _wstat
|
2001-12-31 00:45:29 +00:00
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
#else // !wxUSE_UNICODE
|
2003-04-28 21:09:58 +00:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#define wxOpen open
|
|
|
|
#else
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxOpen _open
|
2003-04-28 21:09:58 +00:00
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxAccess _access
|
|
|
|
#define wxMkDir _mkdir
|
2003-10-16 11:23:07 +00:00
|
|
|
#ifdef __WATCOMC__
|
|
|
|
#define wxRmDir rmdir
|
|
|
|
#else
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxRmDir _rmdir
|
2003-10-16 11:23:07 +00:00
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxStat _stat
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// types
|
2003-09-30 12:41:46 +00:00
|
|
|
#if defined(__WATCOMC__)&& wxUSE_UNICODE
|
|
|
|
#define wxStructStat struct _wstat
|
|
|
|
#else
|
2000-07-15 19:51:35 +00:00
|
|
|
#define wxStructStat struct _stat
|
2003-09-30 12:41:46 +00:00
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
// constants (unless already defined by the user code)
|
2003-09-30 12:41:46 +00:00
|
|
|
#if !defined(O_RDONLY) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
|
2000-07-15 19:51:35 +00:00
|
|
|
#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
|
2003-04-28 20:58:29 +00:00
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2003-09-30 12:41:46 +00:00
|
|
|
#if !defined(__BORLANDC__) && !defined(__WATCOMC__)
|
2000-07-15 19:51:35 +00:00
|
|
|
#define S_IFMT _S_IFMT
|
|
|
|
#define S_IFDIR _S_IFDIR
|
|
|
|
#define S_IFREG _S_IFREG
|
|
|
|
#endif // O_RDONLY
|
|
|
|
#else
|
|
|
|
// functions
|
|
|
|
#define wxClose close
|
|
|
|
#define wxRead read
|
|
|
|
#define wxWrite write
|
|
|
|
#define wxLseek lseek
|
|
|
|
#define wxFsync commit
|
|
|
|
#define wxEof eof
|
|
|
|
|
|
|
|
#define wxMkDir mkdir
|
|
|
|
#define wxRmDir rmdir
|
|
|
|
|
|
|
|
#define wxTell(fd) lseek(fd, 0, SEEK_CUR)
|
|
|
|
|
|
|
|
#define wxStructStat struct stat
|
2002-08-08 21:44:50 +00:00
|
|
|
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
# define wxNEED_WX_UNISTD_H
|
2003-03-27 20:14:39 +00:00
|
|
|
#if defined(__MWERKS__) && defined(macintosh)
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
2004-02-07 15:07:08 +00:00
|
|
|
#if defined(__DMC__)
|
|
|
|
typedef unsigned long mode_t;
|
|
|
|
#endif
|
2003-07-02 01:59:24 +00:00
|
|
|
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 );
|
2002-08-08 21:44:50 +00:00
|
|
|
#else
|
|
|
|
#define wxOpen open
|
|
|
|
#define wxStat stat
|
|
|
|
#define wxAccess access
|
|
|
|
#endif
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
#endif // VC++
|
|
|
|
|
1998-07-14 22:15:29 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// functions
|
|
|
|
// ----------------------------------------------------------------------------
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxFileExists(const wxString& filename);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// does the path exist? (may have or not '/' or '\\' at the end)
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxPathExists(const wxChar *pszPathName);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxIsAbsolutePath(const wxString& filename);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Get filename
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxFileNameFromPath(wxChar *path);
|
|
|
|
WXDLLIMPEXP_BASE wxString wxFileNameFromPath(const wxString& path);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Get directory
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxString wxPathOnly(const wxString& path);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// wxString version
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxString wxRealPath(const wxString& path);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxDos2UnixFilename(wxChar *s);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxUnix2DosFilename(wxChar *s);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Strip the extension, in situ
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxStripExtension(wxChar *buffer);
|
|
|
|
WXDLLIMPEXP_BASE void wxStripExtension(wxString& buffer);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2001-12-01 17:18:11 +00:00
|
|
|
// Get a temporary filename
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL);
|
|
|
|
WXDLLIMPEXP_BASE bool wxGetTempFileName(const wxString& prefix, wxString& buf);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Expand file name (~/ and ${OPENWINHOME}/ stuff)
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxExpandPath(wxChar *dest, const wxChar *path);
|
|
|
|
WXDLLIMPEXP_BASE bool wxExpandPath(wxString& dest, const wxChar *path);
|
1998-05-20 14:01:55 +00: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-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxContractPath(const wxString& filename,
|
2001-12-01 17:18:11 +00:00
|
|
|
const wxString& envname = wxEmptyString,
|
|
|
|
const wxString& user = wxEmptyString);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Destructive removal of /./ and /../ stuff
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxRealPath(wxChar *path);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Allocate a copy of the full absolute path
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxCopyAbsolutePath(const wxString& path);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Get first file name matching given wild card.
|
|
|
|
// Flags are reserved for future use.
|
|
|
|
#define wxFILE 1
|
|
|
|
#define wxDIR 2
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxString wxFindFirstFile(const wxChar *spec, int flags = wxFILE);
|
|
|
|
WXDLLIMPEXP_BASE wxString wxFindNextFile();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Does the pattern contain wildcards?
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxIsWild(const wxString& pattern);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Does the pattern match the text (usually a filename)?
|
|
|
|
// If dot_special is TRUE, doesn't match * against . (eliminating
|
|
|
|
// `hidden' dot files)
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxMatchWild(const wxString& pattern, const wxString& text, bool dot_special = TRUE);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Concatenate two files to form third
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxConcatFiles(const wxString& file1, const wxString& file2, const wxString& file3);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Copy file1 to file2
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxCopyFile(const wxString& file1, const wxString& file2,
|
2001-04-09 00:10:21 +00:00
|
|
|
bool overwrite = TRUE);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Remove file
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxRemoveFile(const wxString& file);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Rename file
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxRenameFile(const wxString& file1, const wxString& file2);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Get current working directory.
|
|
|
|
// 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!
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxChar* wxGetWorkingDirectory(wxChar *buf = (wxChar *) NULL, int sz = 1000);
|
1999-02-09 17:04:29 +00:00
|
|
|
// new and preferred version of wxGetWorkingDirectory
|
|
|
|
// NB: can't have the same name because of overloading ambiguity
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxString wxGetCwd();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Set working directory
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxSetWorkingDirectory(const wxString& d);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Make directory
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxMkdir(const wxString& dir, int perm = 0777);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Remove directory. Flags reserved for future use.
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxRmdir(const wxString& dir, int flags = 0);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
// compatibility defines, don't use in new code
|
|
|
|
#define wxDirExists wxPathExists
|
|
|
|
|
2001-11-30 23:38:06 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 14:01:55 +00:00
|
|
|
// separators in file names
|
2001-11-30 23:38:06 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// between file name and extension
|
1999-10-08 14:35:56 +00:00
|
|
|
#define wxFILE_SEP_EXT wxT('.')
|
2001-11-30 23:38:06 +00:00
|
|
|
|
|
|
|
// between drive/volume name and the path
|
1999-10-08 14:35:56 +00:00
|
|
|
#define wxFILE_SEP_DSK wxT(':')
|
2001-11-30 23:38:06 +00:00
|
|
|
|
|
|
|
// between the path components
|
1999-10-08 14:35:56 +00:00
|
|
|
#define wxFILE_SEP_PATH_DOS wxT('\\')
|
|
|
|
#define wxFILE_SEP_PATH_UNIX wxT('/')
|
2000-12-31 00:23:09 +00:00
|
|
|
#define wxFILE_SEP_PATH_MAC wxT(':')
|
2001-11-30 23:38:06 +00:00
|
|
|
#define wxFILE_SEP_PATH_VMS wxT('.') // VMS also uses '[' and ']'
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// separator in the path list (as in PATH environment variable)
|
2001-02-15 21:51:14 +00: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 14:01:55 +00:00
|
|
|
// NB: these are strings and not characters on purpose!
|
1999-10-08 14:35:56 +00:00
|
|
|
#define wxPATH_SEP_DOS wxT(";")
|
|
|
|
#define wxPATH_SEP_UNIX wxT(":")
|
2001-02-15 21:51:14 +00:00
|
|
|
#define wxPATH_SEP_MAC wxT(";")
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// platform independent versions
|
2003-11-23 22:09:14 +00:00
|
|
|
#if defined(__UNIX__) && !defined(__CYGWIN__) && !defined(__OS2__)
|
1999-02-09 17:04:29 +00:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_UNIX
|
|
|
|
#define wxPATH_SEP wxPATH_SEP_UNIX
|
2000-12-31 00:23:09 +00:00
|
|
|
#elif defined(__MAC__)
|
2001-05-24 21:22:04 +00:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_MAC
|
2001-10-14 08:21:22 +00:00
|
|
|
#define wxPATH_SEP wxPATH_SEP_MAC
|
2002-01-28 22:37:48 +00:00
|
|
|
#elif defined(__CYGWIN__) // Cygwin
|
2002-01-26 17:02:45 +00:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
|
|
|
#define wxPATH_SEP wxPATH_SEP_UNIX
|
1999-07-28 03:38:12 +00:00
|
|
|
#else // Windows and OS/2
|
1999-02-09 17:04:29 +00:00
|
|
|
#define wxFILE_SEP_PATH wxFILE_SEP_PATH_DOS
|
|
|
|
#define wxPATH_SEP wxPATH_SEP_DOS
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif // Unix/Windows
|
|
|
|
|
1998-07-14 21:55:17 +00:00
|
|
|
// this is useful for wxString::IsSameAs(): to compare two file names use
|
|
|
|
// filename1.IsSameAs(filename2, wxARE_FILENAMES_CASE_SENSITIVE)
|
2003-11-23 22:09:14 +00:00
|
|
|
#if defined(__UNIX__) && !defined(__DARWIN__) && !defined(__OS2__)
|
1998-07-14 21:55:17 +00:00
|
|
|
#define wxARE_FILENAMES_CASE_SENSITIVE TRUE
|
2001-10-14 08:21:22 +00:00
|
|
|
#else // Windows, Mac OS and OS/2
|
1998-07-14 21:55:17 +00:00
|
|
|
#define wxARE_FILENAMES_CASE_SENSITIVE FALSE
|
|
|
|
#endif // Unix/Windows
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
// is the char a path separator?
|
1999-04-12 22:20:19 +00:00
|
|
|
inline bool wxIsPathSeparator(wxChar c)
|
2002-01-04 01:39:22 +00:00
|
|
|
{
|
|
|
|
// under DOS/Windows we should understand both Unix and DOS file separators
|
2003-11-23 22:09:14 +00:00
|
|
|
#if ( defined(__UNIX__) && !defined(__OS2__) )|| defined(__MAC__)
|
2002-01-04 01:39:22 +00:00
|
|
|
return c == wxFILE_SEP_PATH;
|
|
|
|
#else
|
|
|
|
return c == wxFILE_SEP_PATH_DOS || c == wxFILE_SEP_PATH_UNIX;
|
|
|
|
#endif
|
|
|
|
}
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// does the string ends with path separator?
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxEndsWithPathSeparator(const wxChar *pszFileName);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-07-14 21:55:17 +00:00
|
|
|
// split the full path into path (including drive for DOS), name and extension
|
|
|
|
// (understands both '/' and '\\')
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxSplitPath(const wxChar *pszFileName,
|
1998-07-14 21:55:17 +00:00
|
|
|
wxString *pstrPath,
|
|
|
|
wxString *pstrName,
|
|
|
|
wxString *pstrExt);
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
// find a file in a list of directories, returns false if not found
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE bool wxFindFileInPath(wxString *pStr, const wxChar *pszPath, const wxChar *pszFile);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-02-06 13:32:46 +00:00
|
|
|
// Get the OS directory if appropriate (such as the Windows directory).
|
|
|
|
// On non-Windows platform, probably just return the empty string.
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE wxString wxGetOSDirectory();
|
1999-02-06 13:32:46 +00:00
|
|
|
|
2000-01-19 01:00:25 +00:00
|
|
|
// Get file modification time
|
2003-07-02 01:59:24 +00:00
|
|
|
WXDLLIMPEXP_BASE time_t wxFileModificationTime(const wxString& filename);
|
2000-01-19 01:00:25 +00:00
|
|
|
|
1998-07-14 22:15:29 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
// Path searching
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxPathList : public wxStringList
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-11-29 22:21:32 +00: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 19:52:35 +00:00
|
|
|
// avoid GCC warning about virtual functions w/o virtual dtor
|
|
|
|
virtual ~wxPathList() {}
|
|
|
|
|
1999-02-09 17:04:29 +00:00
|
|
|
// Adds all paths in environment variable
|
|
|
|
void AddEnvList(const wxString& envVariable);
|
1999-01-26 11:51:12 +00:00
|
|
|
|
1998-11-29 22:21:32 +00:00
|
|
|
void Add(const wxString& path);
|
1999-02-09 17:04:29 +00: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);
|
|
|
|
// Returns TRUE if the path is in the list
|
1998-11-29 22:21:32 +00: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 19:52:35 +00:00
|
|
|
// DECLARE_DYNAMIC_CLASS(wxPathList)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_FILEFN_H_
|