~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

  • Committer: Brian Aker
  • Date: 2010-12-27 20:04:50 UTC
  • mto: (2060.2.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2063.
  • Revision ID: brian@tangent.org-20101227200450-dmxpemwyfmlinlnm
Merge in first pass.

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>
 
28
#include "config.h"
29
29
 
30
 
#include <drizzled/definitions.h>
 
30
#include "drizzled/definitions.h"
31
31
 
32
32
#include <sys/types.h>
33
33
#include <sys/stat.h>
36
36
#include <strings.h>
37
37
#include <limits.h>
38
38
 
39
 
#include <drizzled/cached_directory.h>
 
39
#include "drizzled/cached_directory.h"
40
40
 
41
41
using namespace std;
42
42
 
50
50
 
51
51
 
52
52
CachedDirectory::CachedDirectory(const string &in_path) :
53
 
  error(0),
54
 
  use_full_path(false)
 
53
  error(0)
55
54
{
56
55
  // TODO: Toss future exception
57
56
  (void) open(in_path);
59
58
 
60
59
 
61
60
CachedDirectory::CachedDirectory(const string& in_path, set<string>& allowed_exts) :
62
 
  error(0),
63
 
  use_full_path(false)
 
61
  error(0)
64
62
{
65
63
  // TODO: Toss future exception
66
64
  (void) open(in_path, allowed_exts);
67
65
}
68
66
 
69
 
CachedDirectory::CachedDirectory(const string& in_path, enum CachedDirectory::FILTER filter, bool use_full_path_arg) :
70
 
  error(0),
71
 
  use_full_path(use_full_path_arg)
 
67
CachedDirectory::CachedDirectory(const string& in_path, enum CachedDirectory::FILTER filter) :
 
68
  error(0)
72
69
{
73
70
  set<string> empty;
74
71
  // TODO: Toss future exception
78
75
 
79
76
CachedDirectory::~CachedDirectory()
80
77
{
81
 
  for (Entries::iterator iter= entries.begin(); iter != entries.end(); ++iter)
 
78
  for (Entries::iterator p= entries.begin(); p != entries.end(); ++p)
82
79
  {
83
 
    delete *iter;
 
80
    if (*p)
 
81
      delete *p;
84
82
  }
85
83
  entries.clear();
86
84
}
130
128
         result != NULL)
131
129
  {
132
130
    std::string buffered_fullpath;
133
 
    if (not allowed_exts.empty())
 
131
    if (! allowed_exts.empty())
134
132
    {
135
133
      char *ptr= rindex(result->d_name, '.');
136
134
 
156
154
          if (result->d_name[0] == '.') // We don't pass back anything hidden at the moment.
157
155
            continue;
158
156
 
159
 
          if (use_full_path)
160
 
          {
161
 
            buffered_fullpath.append(in_path);
162
 
            if (buffered_fullpath[buffered_fullpath.length()] != '/')
163
 
              buffered_fullpath.append(1, FN_LIBCHAR);
164
 
          }
 
157
          buffered_fullpath.append(in_path);
 
158
          if (buffered_fullpath[buffered_fullpath.length()] != '/')
 
159
            buffered_fullpath.append(1, FN_LIBCHAR);
165
160
 
166
 
          buffered_fullpath.append(result->d_name);
 
161
          buffered_fullpath.assign(result->d_name);
167
162
 
168
163
          stat(buffered_fullpath.c_str(), &entrystat);
169
164