~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

  • Committer: Jay Pipes
  • Date: 2010-03-09 20:02:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1339.
  • Revision ID: jpipes@serialcoder-20100309200229-dfrliy4fads9vyf4
Fixes Bug #535296 by only incrementing ha_commit_count when its a normal transaction commit.

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
25
25
 *   Implementation of CachedDirectory class.
26
26
 */
27
27
 
28
 
#include <config.h>
29
 
 
30
 
#include <drizzled/definitions.h>
 
28
#include "config.h"
31
29
 
32
30
#include <sys/types.h>
33
31
#include <sys/stat.h>
36
34
#include <strings.h>
37
35
#include <limits.h>
38
36
 
39
 
#include <drizzled/cached_directory.h>
 
37
#include "drizzled/cached_directory.h"
40
38
 
41
39
using namespace std;
42
40
 
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
78
73
 
79
74
CachedDirectory::~CachedDirectory()
80
75
{
81
 
  for (Entries::iterator iter= entries.begin(); iter != entries.end(); ++iter)
 
76
  for (Entries::iterator p= entries.begin(); p != entries.end(); ++p)
82
77
  {
83
 
    delete *iter;
 
78
    if (*p)
 
79
      delete *p;
84
80
  }
85
81
  entries.clear();
86
82
}
129
125
  while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
130
126
         result != NULL)
131
127
  {
132
 
    std::string buffered_fullpath;
133
 
    if (not allowed_exts.empty())
 
128
    if (! allowed_exts.empty())
134
129
    {
135
130
      char *ptr= rindex(result->d_name, '.');
136
131
 
153
148
        {
154
149
          struct stat entrystat;
155
150
 
156
 
          if (result->d_name[0] == '.') // We don't pass back anything hidden at the moment.
 
151
          if (result->d_name[0] == '.')
157
152
            continue;
158
153
 
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
 
          }
165
 
 
166
 
          buffered_fullpath.append(result->d_name);
167
 
 
168
 
          stat(buffered_fullpath.c_str(), &entrystat);
 
154
          stat(result->d_name, &entrystat);
169
155
 
170
156
          if (S_ISDIR(entrystat.st_mode))
171
157
          {
177
163
        {
178
164
          struct stat entrystat;
179
165
 
180
 
          buffered_fullpath.append(in_path);
181
 
          if (buffered_fullpath[buffered_fullpath.length()] != '/')
182
 
            buffered_fullpath.append(1, FN_LIBCHAR);
183
 
 
184
 
          buffered_fullpath.assign(result->d_name);
185
 
 
186
 
          stat(buffered_fullpath.c_str(), &entrystat);
 
166
          stat(result->d_name, &entrystat);
187
167
 
188
168
          if (S_ISREG(entrystat.st_mode))
189
169
          {