udir.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  udir.hpp
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2005 Eric Lecolinet / ENST Paris
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _udir_hpp_
00021 #define _udir_hpp_
00022 #include <ubit/ufile.hpp>
00023 #include <ubit/ustr.hpp>
00024 //pragma ident  "@(#)udir.hpp   ubit:05.05.00"
00025 namespace ubit {
00026 
00027 /* ==================================================== ======== ======= */
00030 class UDir {
00031 public:
00032   UDir();
00033   UDir(const UStr& dirpath);
00034   virtual ~UDir();
00035 
00036   void readDir(const UStr& path, int path_type,
00037                const UStr& prefix, const UStr& filter, bool hidden_files);
00045   UStr& getPath() const {return *dir_info.pname;}
00052   static void expandDirPath(UStr& dirpath);
00053 
00054   std::vector<UFileInfo*> getFileInfos() const {return files;}
00055   UFileInfo* getFileInfo(int k) const {return files[k];}
00056 
00066   unsigned int getFileCount() const {return files.size();}
00068   
00069   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00070   //    Impl.
00071   
00072 protected:
00073   friend class UIconbox;
00074   UFileInfo dir_info;
00075   //bool want_attributes;
00076   std::vector<UFileInfo*> files;
00077   std::vector<UStr*> filters;
00078 
00079   static bool compareEntries(const UFileInfo*, const UFileInfo*);
00080 
00081   void readLocalDir(const UStr& path, const UStr& prefix,
00082                     const UStr& filter, bool hidden_files);
00083 
00084   void readSshDir(const UStr& path, const UStr& prefix,
00085                   const UStr& filter, bool hidden_files);
00086   
00087   static void parseFilter(std::vector<UStr*>& filter_list,
00088                           const UStr& filter_str);
00089 };
00090 
00091 }
00092 #endif
00093 /* ==================================================== [TheEnd] ======= */
00094 /* ==================================================== [(c)Elc] ======= */

Generated on Mon Jan 29 00:20:37 2007 for Ubit by  doxygen 1.4.7