drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
cached_directory.h
Go to the documentation of this file.
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
27
28#pragma once
29
30#include <iosfwd>
31#include <vector>
32#include <set>
33#include <string>
34#include <cstdlib>
35#include <cerrno>
36
37namespace drizzled {
38
46{
47public:
48 enum FILTER
49 {
50 NONE,
51 DIRECTORY,
52 FILE,
53 MAX
54 };
55
56 class Entry
57 {
58 Entry();
59 public:
60 std::string filename;
61 explicit Entry(std::string in_name)
62 : filename(in_name)
63 {}
64 };
65 typedef std::vector<Entry *> Entries;
70
77 CachedDirectory(const std::string& in_path);
78
85 CachedDirectory(const std::string& in_path, std::set<std::string>& allowed_exts);
86 CachedDirectory(const std::string& in_path, CachedDirectory::FILTER filter, bool use_full_path= false);
87
92
96 inline bool fail() const
97 {
98 return error != 0;
99 }
100
105 inline int getError() const
106 {
107 return error;
108 }
109
113 inline const char *getPath() const
114 {
115 return path.c_str();
116 }
117
124 const Entries &getEntries() const
125 {
126 return entries;
127 }
128private:
129 std::string path;
130 int error;
131 bool use_full_path;
132 Entries entries;
133
141 bool open(const std::string &in_path);
142
153 bool open(const std::string &in_path, std::set<std::string> &allowable_exts);
154 bool open(const std::string &in_path, std::set<std::string> &allowed_exts, CachedDirectory::FILTER filter);
155
156 friend std::ostream& operator<<(std::ostream&, const CachedDirectory&);
157};
158
159} /* namespace drizzled */
160
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.