~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/cached_directory.cc

  • Committer: Brian Aker
  • Date: 2009-11-04 23:19:25 UTC
  • mfrom: (1200.2.4 working)
  • Revision ID: brian@gaz-20091104231925-dzkbu681c9x2lan7
Merge Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
}
47
47
 
48
48
 
49
 
CachedDirectory::CachedDirectory(const string& in_path, set<string>& exts) :
 
49
CachedDirectory::CachedDirectory(const string& in_path, set<string>& allowed_exts) :
50
50
  error(0)
51
51
{
52
52
  // TODO: Toss future exception
53
 
  (void) open(in_path, exts, true);
 
53
  (void) open(in_path, allowed_exts);
54
54
}
55
55
 
56
56
 
64
64
  entries.clear();
65
65
}
66
66
 
67
 
 
68
67
bool CachedDirectory::open(const string &in_path)
69
68
{
70
69
  set<string> empty;
71
70
 
72
 
  return open(in_path, empty, false);
 
71
  return open(in_path, empty);
73
72
}
74
73
 
75
 
bool CachedDirectory::open(const string &in_path, set<string> exts, bool honor_exts)
 
74
bool CachedDirectory::open(const string &in_path, set<string> &allowed_exts)
76
75
{
77
76
  DIR *dirp= opendir(in_path.c_str());
78
77
 
84
83
 
85
84
  path= in_path;
86
85
 
87
 
  if (exts.size() == 0 && honor_exts)
88
 
    return true;
89
 
 
90
86
  union {
91
87
    dirent entry;
92
88
#ifdef __sun
107
103
  while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
108
104
         result != NULL)
109
105
  {
110
 
    if (exts.size())
 
106
    if (! allowed_exts.empty())
111
107
    {
112
108
      char *ptr= rindex(result->d_name, '.');
113
109
 
114
110
      if (ptr)
115
111
      {
116
112
        set<string>::iterator it;
117
 
        it= exts.find(ptr);
 
113
        it= allowed_exts.find(ptr);
118
114
 
119
 
        if (it != exts.end())
 
115
        if (it != allowed_exts.end())
120
116
        {
121
117
          entries.push_back(new Entry(result->d_name));
122
118
        }