Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

DirectoryEntry.h

Go to the documentation of this file.
00001 
00002 // Name:        DirectoryEntry.h
00003 // Purpose:     Represents a single file or directory
00004 // Author:      Joe Yates
00005 // Modified by:
00006 // Created:     11/10/2004
00007 // RCS-ID:      $Id: DirectoryEntry.h,v 1.1.1.1 2006/01/24 22:13:19 titusd Exp $
00008 // Copyright:   (c) BID Snc
00009 // License:     BSD license (see the file 'LICENSE.txt')
00011 
00012 #ifndef __DirectoryEntry_h__
00013 #define __DirectoryEntry_h__
00014 
00015 #include <sys/stat.h>
00016 #ifdef __UNIX__
00017 #include <unistd.h>
00018 #endif // def __UNIX__
00019 
00020 #ifdef __UNIX__
00021 # define STAT(x,y) lstat(x,y)
00022 # define STRUCT_STAT stat
00023 #elif defined __WXMSW__
00024 # define STRUCT_STAT _stat
00025 
00026 # ifdef wxUSE_UNICODE
00027 #   define STAT(x, y) _wstat(x, y)
00028 # else
00029 #   define STAT(x, y) _stat(x, y)
00030 # endif // wxUSE_UNICODE
00031 #endif // def OS
00032 
00033 #define MIME_DIRECTORY wxT("Directory")
00034 
00035 enum DirectoryEntryType
00036   {
00037   detNone = 0,
00038   detDirectory,
00039 #ifdef __UNIX__
00040   detCharacterSpecial,
00041   detBlockSpecial,
00042 #endif // def __UNIX__
00043   detFile,
00044 #ifdef __UNIX__
00045   detFIFO,
00046   detLink,
00047 #endif // def __UNIX__
00048   };
00049 
00050 enum DirectoryEntrySortKey
00051   {
00052   desFILENAME = 1,
00053   desMODDATE = 2,
00054   desFILETYPE = 3
00055   };
00056 
00058 // Text sort flags
00059 
00060 #define DIRECTORYENTRY_TEXTSORT_CASESENSITIVE 1
00061 #define DIRECTORYENTRY_TEXTSORT_IGNOREHIDDENDOTS 2
00062 
00063 DirectoryEntryType GetDirectoryEntryType(const wxString& sPath);
00064 DirectoryEntryType GetDirectoryEntryType(const wxString& sPath, struct STRUCT_STAT& st);
00065 
00070 class DirectoryEntry
00071   {
00072   // friends, classes, enums and types
00073   friend class DirectoryEntryArray;
00074 
00075   // Constructors/destructors
00076   public:
00077     DirectoryEntry(const wxString& sNewPath, const wxString& sNewName, DirectoryEntrySortKey desNew, int nTextSortFlags);
00078 
00079   // Operators
00080   public:
00081     bool operator<(const DirectoryEntry& dreOther) const;
00082 
00083   // Methods
00084   public:
00085     wxString            GetPathName() const;
00086     wxString            GetName() const;
00087     DirectoryEntryType  GetType() const;
00088     bool                IsHidden() const;
00089     bool                CanExecute() const;
00090     int                 GetPermissions() const;
00091     time_t              GetModificationTime() const;
00092     wxString            GetDescription() const;
00093     int                 GetImageIndex() const;
00094     wxString            GetFileType() const;
00095     bool                Activate() const;
00096     
00097     // Get the full description and image index
00098     // 'true' return means the value was updated
00099     bool                CacheValues();
00100 
00101   protected:
00102     wxString            GetCompareName() const;
00103 
00104   private:
00105     bool                CompareByName(const DirectoryEntry& dreOther) const;
00106     bool                CompareByModificationDate(const DirectoryEntry& dreOther) const;
00107 
00108   // Members
00109   private:
00110     wxString            m_sPathName;
00111     wxString            m_sPath;
00112     wxString            m_sName;
00113     DirectoryEntryType  m_det;
00114     bool                m_bIsHidden;
00115     // Sort-related members
00116     DirectoryEntrySortKey m_des;
00117     bool                m_bCaseSensitive;
00118     bool                m_bIgnoreHiddenDots;
00119 
00120     // Cached values
00121     // 'm_sCompareName' is used to compare this file name with others
00122     wxString            m_sCompareName;
00123     bool                m_bCacheValuesLoaded;
00124     // 'sDescription' is the full description, with file type, link destination, etc
00125     wxString            m_sDescription;
00126     int                 m_nImageIndex;
00127     wxString            m_sFileType;
00128     struct STRUCT_STAT  m_st;
00129   };
00130 
00131 #endif // ndef __DirectoryEntry_h__

Generated on Wed Jan 25 08:14:45 2006 for Sherpa by doxygen 1.3.6