Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00028 #pragma once
00029
00030 #include <iosfwd>
00031 #include <vector>
00032 #include <set>
00033 #include <string>
00034 #include <cstdlib>
00035 #include <cerrno>
00036
00037 namespace drizzled {
00038
00045 class CachedDirectory
00046 {
00047 public:
00048 enum FILTER
00049 {
00050 NONE,
00051 DIRECTORY,
00052 FILE,
00053 MAX
00054 };
00055
00056 class Entry
00057 {
00058 Entry();
00059 public:
00060 std::string filename;
00061 explicit Entry(std::string in_name)
00062 : filename(in_name)
00063 {}
00064 };
00065 typedef std::vector<Entry *> Entries;
00069 CachedDirectory();
00070
00077 CachedDirectory(const std::string& in_path);
00078
00085 CachedDirectory(const std::string& in_path, std::set<std::string>& allowed_exts);
00086 CachedDirectory(const std::string& in_path, CachedDirectory::FILTER filter, bool use_full_path= false);
00087
00091 ~CachedDirectory();
00092
00096 inline bool fail() const
00097 {
00098 return error != 0;
00099 }
00100
00105 inline int getError() const
00106 {
00107 return error;
00108 }
00109
00113 inline const char *getPath() const
00114 {
00115 return path.c_str();
00116 }
00117
00124 const Entries &getEntries() const
00125 {
00126 return entries;
00127 }
00128 private:
00129 std::string path;
00130 int error;
00131 bool use_full_path;
00132 Entries entries;
00133
00141 bool open(const std::string &in_path);
00142
00153 bool open(const std::string &in_path, std::set<std::string> &allowable_exts);
00154 bool open(const std::string &in_path, std::set<std::string> &allowed_exts, CachedDirectory::FILTER filter);
00155
00156 friend std::ostream& operator<<(std::ostream&, const CachedDirectory&);
00157 };
00158
00159 }
00160