00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _udir_hpp_
00025 #define _udir_hpp_
00026 #include <sys/stat.h>
00027
00028 class UDir {
00029 public:
00030
00031 struct Entry {
00032 Entry(const class UDir& dir, const char* dname);
00033
00034 bool isDir() const;
00035 bool isFile() const;
00036 bool isLink() const;
00037 bool isExec() const;
00038
00039 UStr* getName() const {return name;}
00041
00042 UIma* getSmallIcon() const;
00043 UIma* getLargeIcon() const;
00045
00046 unsigned long getSize() const {return size;}
00047 mode_t getMode() const {return mode;}
00048 time_t getTime() const {return mtime;}
00049
00050 UStr* createSizeStr() const;
00051 UStr* createModeStr() const;
00052 UStr* createTimeStr() const;
00054
00055
00056
00057 uptr<UStr> name;
00058 unsigned long size;
00059 mode_t mode;
00060 time_t mtime;
00061 };
00062
00063
00064
00065 UDir(const std::string pathname);
00066 UDir(const UStr& pathname);
00067 UDir(const UStr& pathname, const UStr& prefix,
00068 const UStr& filter, bool get_hidden_files);
00076 virtual ~UDir();
00077
00078 const UStr& getPath() const {return path;}
00085 std::vector<UDir::Entry*> getFileEntries() const {return entries;}
00086 UDir::Entry* getFileEntry(int k) const {return entries[k];}
00087
00097 unsigned int getFileCount() const {return entries.size();}
00099
00100
00101
00102
00103 protected:
00104 friend class UDir::Entry;
00105
00106 UStr path;
00107 struct stat& statbuf;
00108 bool want_attributes;
00109 std::vector<UDir::Entry*> entries;
00110 std::vector<UStr*> filters;
00111
00112 virtual void constructs(const UStr& pathname, const UStr& prefix,
00113 const UStr& filter, bool get_hidden_files);
00114 public:
00115 static void parseDir(UStr& pathname);
00116 static void parseFilter(std::vector<UStr*>& filter_list,
00117 const UStr& filter_str);
00118 static bool compareEntries(const UDir::Entry*, const UDir::Entry*);
00119 };
00120
00121
00122
00123 #endif