~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

Updating test cases + added Drizzle specific schema_names and schema_info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "config.h"
29
29
 
 
30
#include <sys/types.h>
 
31
#include <sys/stat.h>
 
32
#include <unistd.h>
 
33
 
30
34
#include <strings.h>
31
35
#include <limits.h>
32
36
 
58
62
  (void) open(in_path, allowed_exts);
59
63
}
60
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
 
61
73
 
62
74
CachedDirectory::~CachedDirectory()
63
75
{
78
90
 
79
91
bool CachedDirectory::open(const string &in_path, set<string> &allowed_exts)
80
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
{
81
98
  DIR *dirp= opendir(in_path.c_str());
82
99
 
83
100
  if (dirp == NULL)
125
142
    }
126
143
    else
127
144
    {
128
 
      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
      }
129
179
    }
130
180
  }
131
181