~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

  • Committer: Brian Aker
  • Date: 2010-07-30 20:31:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1679.
  • Revision ID: brian@gaz-20100730203119-89g2ye4zwnvcacxg
First pass in encapsulating row

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
27
27
 
28
28
#include "config.h"
29
29
 
30
 
#include "drizzled/definitions.h"
31
 
 
32
30
#include <sys/types.h>
33
31
#include <sys/stat.h>
34
32
#include <unistd.h>
50
48
 
51
49
 
52
50
CachedDirectory::CachedDirectory(const string &in_path) :
53
 
  error(0),
54
 
  use_full_path(false)
 
51
  error(0)
55
52
{
56
53
  // TODO: Toss future exception
57
54
  (void) open(in_path);
59
56
 
60
57
 
61
58
CachedDirectory::CachedDirectory(const string& in_path, set<string>& allowed_exts) :
62
 
  error(0),
63
 
  use_full_path(false)
 
59
  error(0)
64
60
{
65
61
  // TODO: Toss future exception
66
62
  (void) open(in_path, allowed_exts);
67
63
}
68
64
 
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)
 
65
CachedDirectory::CachedDirectory(const string& in_path, enum CachedDirectory::FILTER filter) :
 
66
  error(0)
72
67
{
73
68
  set<string> empty;
74
69
  // TODO: Toss future exception
130
125
  while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
131
126
         result != NULL)
132
127
  {
133
 
    std::string buffered_fullpath;
134
 
    if (not allowed_exts.empty())
 
128
    if (! allowed_exts.empty())
135
129
    {
136
130
      char *ptr= rindex(result->d_name, '.');
137
131
 
154
148
        {
155
149
          struct stat entrystat;
156
150
 
157
 
          if (result->d_name[0] == '.') // We don't pass back anything hidden at the moment.
 
151
          if (result->d_name[0] == '.')
158
152
            continue;
159
153
 
160
 
          if (use_full_path)
161
 
          {
162
 
            buffered_fullpath.append(in_path);
163
 
            if (buffered_fullpath[buffered_fullpath.length()] != '/')
164
 
              buffered_fullpath.append(1, FN_LIBCHAR);
165
 
          }
166
 
 
167
 
          buffered_fullpath.append(result->d_name);
168
 
 
169
 
          stat(buffered_fullpath.c_str(), &entrystat);
 
154
          stat(result->d_name, &entrystat);
170
155
 
171
156
          if (S_ISDIR(entrystat.st_mode))
172
157
          {
178
163
        {
179
164
          struct stat entrystat;
180
165
 
181
 
          buffered_fullpath.append(in_path);
182
 
          if (buffered_fullpath[buffered_fullpath.length()] != '/')
183
 
            buffered_fullpath.append(1, FN_LIBCHAR);
184
 
 
185
 
          buffered_fullpath.assign(result->d_name);
186
 
 
187
 
          stat(buffered_fullpath.c_str(), &entrystat);
 
166
          stat(result->d_name, &entrystat);
188
167
 
189
168
          if (S_ISREG(entrystat.st_mode))
190
169
          {