00001
00002
00003
00004
00005
00006
00007
00008
00009
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
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
00073 friend class DirectoryEntryArray;
00074
00075
00076 public:
00077 DirectoryEntry(const wxString& sNewPath, const wxString& sNewName, DirectoryEntrySortKey desNew, int nTextSortFlags);
00078
00079
00080 public:
00081 bool operator<(const DirectoryEntry& dreOther) const;
00082
00083
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
00098
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
00109 private:
00110 wxString m_sPathName;
00111 wxString m_sPath;
00112 wxString m_sName;
00113 DirectoryEntryType m_det;
00114 bool m_bIsHidden;
00115
00116 DirectoryEntrySortKey m_des;
00117 bool m_bCaseSensitive;
00118 bool m_bIgnoreHiddenDots;
00119
00120
00121
00122 wxString m_sCompareName;
00123 bool m_bCacheValuesLoaded;
00124
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__