~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/cached_directory.cc

Added code necessary for building plugins dynamically.
Merged in changes from lifeless to allow autoreconf to work.
Touching plugin.ini files now triggers a rebuid - so config/autorun.sh is no
longer required to be run after touching those.
Removed the duplicate plugin names - also removed the issue that getting them
different would silently fail weirdly later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *   Implementation of CachedDirectory class.
26
26
 */
27
27
 
 
28
#include <strings.h>
28
29
#include "drizzled/global.h"
29
30
#include "cached_directory.h"
30
31
 
31
32
using namespace std;
32
33
 
33
34
 
34
 
CachedDirectory::CachedDirectory(const string &in_path)
35
 
  : error(0)
36
 
{
 
35
CachedDirectory::CachedDirectory() : 
 
36
  error(0)
 
37
{
 
38
}
 
39
 
 
40
 
 
41
CachedDirectory::CachedDirectory(const string &in_path) :
 
42
  error(0)
 
43
{
 
44
  // TODO: Toss future exception
37
45
  (void) open(in_path);
38
46
}
39
47
 
 
48
 
 
49
CachedDirectory::CachedDirectory(const string& in_path, set<string>& exts) :
 
50
  error(0)
 
51
{
 
52
  // TODO: Toss future exception
 
53
  (void) open(in_path, exts, true);
 
54
}
 
55
 
 
56
 
40
57
CachedDirectory::~CachedDirectory()
41
58
{
42
 
  Entries::iterator p= entries.begin();
43
 
  while (p != entries.end())
 
59
  for (Entries::iterator p= entries.begin(); p != entries.end(); ++p)
44
60
  {
45
61
    if (*p)
46
62
      delete *p;
47
 
    ++p;
48
63
  }
 
64
  entries.clear();
49
65
}
50
66
 
 
67
 
51
68
bool CachedDirectory::open(const string &in_path)
52
69
{
 
70
  set<string> empty;
 
71
 
 
72
  return open(in_path, empty, false);
 
73
}
 
74
 
 
75
bool CachedDirectory::open(const string &in_path, set<string> exts, bool honor_exts)
 
76
{
53
77
  DIR *dirp= opendir(in_path.c_str());
54
78
 
55
79
  if (dirp == NULL)
58
82
    return false;
59
83
  }
60
84
 
 
85
  path= in_path;
 
86
 
 
87
  if (exts.size() == 0 && honor_exts)
 
88
    return true;
 
89
 
61
90
  union {
62
91
    dirent entry;
63
92
#ifdef __sun
77
106
 
78
107
  while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
79
108
         result != NULL)
80
 
    entries.push_back(new Entry(result->d_name));
 
109
  {
 
110
    if (exts.size())
 
111
    {
 
112
      char *ptr= rindex(result->d_name, '.');
 
113
 
 
114
      if (ptr)
 
115
      {
 
116
        set<string>::iterator it;
 
117
        it= exts.find(ptr);
 
118
 
 
119
        if (it != exts.end())
 
120
        {
 
121
          entries.push_back(new Entry(result->d_name));
 
122
        }
 
123
      }
 
124
    }
 
125
    else
 
126
    {
 
127
      entries.push_back(new Entry(result->d_name));
 
128
    }
 
129
  }
81
130
    
82
131
  closedir(dirp);
83
132
  error= retcode;