40#include <drizzled/util/find_ptr.h>
41#include <drizzled/error_t.h>
42#include <drizzled/error.h>
43#include <drizzled/errmsg_print.h>
70 (void)
open(in_path, allowed_exts);
75 use_full_path(use_full_path_arg)
79 (void)
open(in_path, empty, filter);
85 for (Entries::reference iter :
entries)
92 return open(in_path, empty);
97 return open(in_path, allowed_exts, CachedDirectory::NONE);
100bool CachedDirectory::open(
const string &in_path, set<string> &allowed_exts,
enum CachedDirectory::FILTER filter)
102 DIR *dirp= opendir(in_path.c_str());
116 while ((result= readdir(dirp)) != NULL)
118 std::string buffered_fullpath;
119 if (not allowed_exts.empty())
121 char *ptr= rindex(result->d_name,
'.');
122 if (ptr && allowed_exts.count(ptr))
124 entries.push_back(
new Entry(result->d_name));
133 struct stat entrystat;
135 if (result->d_name[0] ==
'.')
140 buffered_fullpath.append(in_path);
141 if (buffered_fullpath[buffered_fullpath.length()] !=
'/')
142 buffered_fullpath.append(1, FN_LIBCHAR);
145 buffered_fullpath.append(result->d_name);
147 int err= stat(buffered_fullpath.c_str(), &entrystat);
151 errmsg_printf(error::WARN, ER(ER_CANT_GET_STAT),
152 buffered_fullpath.c_str(),
156 if (err == 0 && S_ISDIR(entrystat.st_mode))
164 struct stat entrystat;
166 buffered_fullpath.append(in_path);
167 if (buffered_fullpath[buffered_fullpath.length() - 1] !=
'/')
168 buffered_fullpath.append(1, FN_LIBCHAR);
170 buffered_fullpath= result->d_name;
172 stat(buffered_fullpath.c_str(), &entrystat);
174 if (S_ISREG(entrystat.st_mode))
195std::ostream& operator<<(std::ostream& output,
const CachedDirectory &directory)
197 output <<
"CachedDirectory:(Path: " << directory.
getPath() <<
")\n";
199 output <<
"\t(" << iter->filename <<
")\n";
Defines the interface to the CachedDirectory class.
const Entries & getEntries() const
std::string path
Path to the directory.
int error
Error code stored from various syscalls.
Entries entries
Entries in the directory.
const char * getPath() const
bool open(const std::string &in_path)
TODO: Rename this file - func.h is stupid.