X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/844f90fba68fc9fbd3e839825d406839ee9fb9fb..8bc3617742deb43c011fa91e840cb7a6d3e9b095:/include/wx/filename.h diff --git a/include/wx/filename.h b/include/wx/filename.h index 9622124d8e..06696bfdf2 100644 --- a/include/wx/filename.h +++ b/include/wx/filename.h @@ -17,11 +17,26 @@ #endif #ifndef WX_PRECOMP - #include "wx/string.h" + #include "wx/string.h" #endif +/* + TODO: + + 1. support for drives under Windows + 2. more file operations: + a) chmod() + b) [acm]time() - get and set + c) file size + d) file permissions with readable accessors for most common bits + such as IsReadable() &c + e) rename()? + 3. SameFileAs() function to compare inodes under Unix + */ + // ridiculously enough, this will replace DirExists with wxDirExists etc #include "wx/filefn.h" +#include "wx/datetime.h" // ---------------------------------------------------------------------------- // constants @@ -51,7 +66,8 @@ enum wxPathNormalize wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user wxPATH_NORM_CASE = 0x0008, // if case insensitive => tolower wxPATH_NORM_ABSOLUTE = 0x0010, // make the path absolute - wxPATH_NORM_ALL = 0x001f + wxPATH_NORM_LONG = 0x0020, // make the path the long form + wxPATH_NORM_ALL = 0x003f }; // ---------------------------------------------------------------------------- @@ -86,14 +102,6 @@ public: wxPathFormat format = wxPATH_NATIVE) { Assign(path, name, ext, format); } - // assorted assignment operators - - wxFileName& operator=(const wxFileName& filename) - { Assign(filename); return *this; } - - wxFileName& operator=(const wxString& filename) - { Assign(filename); return *this; } - // the same for delayed initialization // VZ: wouldn't it be better to call this Create() for consistency with @@ -112,6 +120,14 @@ public: void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE) { Assign(dir, _T(""), format); } + // assorted assignment operators + + wxFileName& operator=(const wxFileName& filename) + { Assign(filename); return *this; } + + wxFileName& operator=(const wxString& filename) + { Assign(filename); return *this; } + // reset all components to default, uninitialized state void Clear(); @@ -132,6 +148,9 @@ public: bool DirExists(); static bool DirExists( const wxString &dir ); + // Well, get modification time with sec resolution + wxDateTime GetModificationTime(); + // VZ: also need: IsDirWritable(), IsFileExecutable() &c (TODO) // various file/dir operations @@ -151,9 +170,10 @@ public: // get a temp file name starting with thespecified prefix void AssignTempFileName( const wxString &prefix ); - // directory creation and removal - bool Mkdir( int perm = 0777 ); - static bool Mkdir( const wxString &dir, int perm = 0777 ); + // 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 Rmdir(); static bool Rmdir( const wxString &dir ); @@ -171,15 +191,15 @@ public: // Comparison + // compares with the rules of this platform + bool SameAs(const wxFileName &filepath, + wxPathFormat format = wxPATH_NATIVE); + // uses the current platform settings bool operator==(const wxFileName& filename) { return SameAs(filename); } bool operator==(const wxString& filename) { return *this == wxFileName(filename); } - // compares with the rules of this platform - bool SameAs(const wxFileName &filepath, - wxPathFormat format = wxPATH_NATIVE); - // Tests static bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE ); bool IsRelative( wxPathFormat format = wxPATH_NATIVE ); @@ -210,12 +230,15 @@ public: wxString GetName() const { return m_name; } bool HasName() const { return !m_name.IsEmpty(); } + // full name is the file name + extension (but without the path) + void SetFullName(const wxString& fullname); wxString GetFullName() const; const wxArrayString &GetDirs() const { return m_dirs; } // Construct path only - possibly with the trailing separator - wxString GetPath( bool add_separator = FALSE, wxPathFormat format = wxPATH_NATIVE ) const; + wxString GetPath( bool add_separator = FALSE, + wxPathFormat format = wxPATH_NATIVE ) const; // more readable synonym wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const @@ -224,8 +247,25 @@ public: // Construct full path with name and ext wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const; + // Return the short form of the path (returns identity on non-Windows platforms) + wxString GetShortPath() const; + + // Return the long form of the path (returns identity on non-Windows platforms) + wxString GetLongPath() const; + + // various helpers + + // get the canonical path format for this platform static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE ); + // split a fullpath into path, (base) name and ext (all of the pointers + // can be NULL) + static void SplitPath(const wxString& fullpath, + wxString *path, + wxString *name, + wxString *ext, + wxPathFormat format = wxPATH_NATIVE); + private: // the path components of the file wxArrayString m_dirs;