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

udir.hpp

00001 /* ==================================================== ======== ======= * 00002 * 00003 * udir.hpp 00004 * Ubit Project [Elc][2003] 00005 * 00006 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00007 * 00008 * (C) 1999-2003 Eric Lecolinet @ ENST Paris 00009 * WWW: http://www.enst.fr/~elc/ubit Email: elc@enst.fr (subject: ubit) 00010 * 00011 * *********************************************************************** 00012 * COPYRIGHT NOTICE : 00013 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00014 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00015 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00016 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00017 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00018 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00019 * *********************************************************************** 00020 * 00021 * ==================================================== [Elc:03] ======= * 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 // Impl. 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 /* ==================================================== [TheEnd] ======= */ 00122 /* ==================================================== [Elc:03] ======= */ 00123 #endif

Generated on Wed Aug 18 07:38:55 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.7