// Created: 28.12.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Robert Roebling
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILENAME_H_
#define _WX_FILENAME_H_
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "filename.h"
#endif
#ifndef WX_PRECOMP
#include "wx/string.h"
+ #include "wx/arrstr.h"
#endif
/*
#include "wx/filefn.h"
#include "wx/datetime.h"
-class WXDLLEXPORT wxFile;
+class WXDLLIMPEXP_BASE wxFile;
// ----------------------------------------------------------------------------
// constants
wxPATH_GET_SEPARATOR = 0x0002 // terminate the path with the separator
};
+// MkDir flags
+enum
+{
+ wxPATH_MKDIR_FULL = 0x0001 // create directories recursively
+};
+
// ----------------------------------------------------------------------------
// wxFileName: encapsulates a file path
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxFileName
+class WXDLLIMPEXP_BASE wxFileName
{
public:
// constructors and assignment
// the usual stuff
- wxFileName() { }
+ wxFileName() { Clear(); }
wxFileName( const wxFileName &filepath ) { Assign(filepath); }
// from a full filename: if it terminates with a '/', a directory path
// file tests
// is the filename valid at all?
- bool IsOk() const { return !m_dirs.IsEmpty() || !m_name.IsEmpty(); }
+ bool IsOk() const { return m_dirs.size() != 0 || !m_name.IsEmpty(); }
// does the file with this name exists?
- bool FileExists();
+ bool FileExists() const;
static bool FileExists( const wxString &file );
// does the directory with this name exists?
- bool DirExists();
+ bool DirExists() const;
static bool DirExists( const wxString &dir );
// VZ: also need: IsDirWritable(), IsFileExecutable() &c (TODO)
// time functions
-
+#if wxUSE_DATETIME
// set the file last access/mod and creation times
// (any of the pointers may be NULL)
bool SetTimes(const wxDateTime *dtAccess,
(void)GetTimes(NULL, &dtMod, NULL);
return dtMod;
}
+#endif // wxUSE_DATETIME
#ifdef __WXMAC__
bool MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) ;
// looks up the appropriate type and creator from the registration and then sets
bool MacSetDefaultTypeAndCreator() ;
#endif
+
// various file/dir operations
// retrieve the value of the current working directory
// directory creation and removal.
// if full is TRUE, will try to make each directory in the path.
- bool Mkdir( int perm = 0777, bool full = FALSE);
- static bool Mkdir( const wxString &dir, int perm = 0777, bool full = FALSE );
+ bool Mkdir( int perm = 0777, int flags = 0);
+ static bool Mkdir( const wxString &dir, int perm = 0777, int flags = 0 );
bool Rmdir();
static bool Rmdir( const wxString &dir );
bool MakeRelativeTo(const wxString& pathBase = _T(""),
wxPathFormat format = wxPATH_NATIVE);
+ // make the path absolute
+ //
+ // this may be done using another (than current) value of cwd
+ bool MakeAbsolute(const wxString& cwd = wxEmptyString,
+ wxPathFormat format = wxPATH_NATIVE)
+ { return Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE |
+ wxPATH_NORM_TILDE, cwd, format); }
// Comparison
- // compares with the rules of this platform
- bool SameAs(const wxFileName &filepath,
- wxPathFormat format = wxPATH_NATIVE);
+ // compares with the rules of the given platforms format
+ bool SameAs(const wxFileName& filepath,
+ wxPathFormat format = wxPATH_NATIVE) const;
- // uses the current platform settings
- bool operator==(const wxFileName& filename) { return SameAs(filename); }
- bool operator==(const wxString& filename)
- { return *this == wxFileName(filename); }
+ // compare with another filename object
+ bool operator==(const wxFileName& filename) const
+ { return SameAs(filename); }
+ bool operator!=(const wxFileName& filename) const
+ { return !SameAs(filename); }
+
+ // compare with a filename string interpreted as a native file name
+ bool operator==(const wxString& filename) const
+ { return SameAs(wxFileName(filename)); }
+ bool operator!=(const wxString& filename) const
+ { return !SameAs(wxFileName(filename)); }
// are the file names of this type cases sensitive?
static bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
void PrependDir( const wxString &dir );
void InsertDir( int before, const wxString &dir );
void RemoveDir( int pos );
- size_t GetDirCount() const { return m_dirs.GetCount(); }
+ size_t GetDirCount() const { return m_dirs.size(); }
// Other accessors
void SetExt( const wxString &ext ) { m_ext = ext; }
// deprecated methods, don't use any more
// --------------------------------------
+#ifndef __DIGITALMARS__
wxString GetPath( bool withSep, wxPathFormat format = wxPATH_NATIVE ) const
{ return GetPath(withSep ? wxPATH_GET_SEPARATOR : 0, format); }
-
+#endif
wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
{ return GetPath(wxPATH_GET_SEPARATOR, format); }