~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

Remove PLUGIN and MODULES.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *   Implementation of CachedDirectory class.
26
26
 */
27
27
 
 
28
#include "config.h"
 
29
 
 
30
#include <sys/types.h>
 
31
#include <sys/stat.h>
 
32
#include <unistd.h>
 
33
 
28
34
#include <strings.h>
29
 
#include "drizzled/global.h"
30
 
#include "cached_directory.h"
 
35
#include <limits.h>
 
36
 
 
37
#include "drizzled/cached_directory.h"
31
38
 
32
39
using namespace std;
33
40
 
 
41
namespace drizzled
 
42
{
34
43
 
35
44
CachedDirectory::CachedDirectory() : 
36
45
  error(0)
53
62
  (void) open(in_path, allowed_exts);
54
63
}
55
64
 
 
65
CachedDirectory::CachedDirectory(const string& in_path, enum CachedDirectory::FILTER filter) :
 
66
  error(0)
 
67
{
 
68
  set<string> empty;
 
69
  // TODO: Toss future exception
 
70
  (void) open(in_path, empty, filter);
 
71
}
 
72
 
56
73
 
57
74
CachedDirectory::~CachedDirectory()
58
75
{
73
90
 
74
91
bool CachedDirectory::open(const string &in_path, set<string> &allowed_exts)
75
92
{
 
93
  return open(in_path, allowed_exts, CachedDirectory::NONE);
 
94
}
 
95
 
 
96
bool CachedDirectory::open(const string &in_path, set<string> &allowed_exts, enum CachedDirectory::FILTER filter)
 
97
{
76
98
  DIR *dirp= opendir(in_path.c_str());
77
99
 
78
100
  if (dirp == NULL)
120
142
    }
121
143
    else
122
144
    {
123
 
      entries.push_back(new Entry(result->d_name));
 
145
      switch (filter)
 
146
      {
 
147
      case DIRECTORY:
 
148
        {
 
149
          struct stat entrystat;
 
150
 
 
151
          if (result->d_name[0] == '.')
 
152
            continue;
 
153
 
 
154
          stat(result->d_name, &entrystat);
 
155
 
 
156
          if (S_ISDIR(entrystat.st_mode))
 
157
          {
 
158
            entries.push_back(new Entry(result->d_name));
 
159
          }
 
160
        }
 
161
        break;
 
162
      case FILE:
 
163
        {
 
164
          struct stat entrystat;
 
165
 
 
166
          stat(result->d_name, &entrystat);
 
167
 
 
168
          if (S_ISREG(entrystat.st_mode))
 
169
          {
 
170
            entries.push_back(new Entry(result->d_name));
 
171
          }
 
172
        }
 
173
        break;
 
174
      case NONE:
 
175
      case MAX:
 
176
        entries.push_back(new Entry(result->d_name));
 
177
        break;
 
178
      }
124
179
    }
125
180
  }
126
181
    
129
184
 
130
185
  return error == 0;
131
186
}
 
187
 
 
188
} /* namespace drizzled */