~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-21 11:23:19 UTC
  • mto: (2100.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2101.
  • Revision ID: andrew@linuxjedi.co.uk-20110121112319-nj1cvg0yt3nnf2rr
Add errors page to drizzle client docs
Add link to specific error in migration docs
Minor changes to migration docs

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
 
30
32
#include <sys/types.h>
31
33
#include <sys/stat.h>
32
34
#include <unistd.h>
48
50
 
49
51
 
50
52
CachedDirectory::CachedDirectory(const string &in_path) :
51
 
  error(0)
 
53
  error(0),
 
54
  use_full_path(false)
52
55
{
53
56
  // TODO: Toss future exception
54
57
  (void) open(in_path);
56
59
 
57
60
 
58
61
CachedDirectory::CachedDirectory(const string& in_path, set<string>& allowed_exts) :
59
 
  error(0)
 
62
  error(0),
 
63
  use_full_path(false)
60
64
{
61
65
  // TODO: Toss future exception
62
66
  (void) open(in_path, allowed_exts);
63
67
}
64
68
 
65
 
CachedDirectory::CachedDirectory(const string& in_path, enum CachedDirectory::FILTER filter) :
66
 
  error(0)
 
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
72
{
68
73
  set<string> empty;
69
74
  // TODO: Toss future exception
125
130
  while ((retcode= readdir_r(dirp, &buffer.entry, &result)) == 0 &&
126
131
         result != NULL)
127
132
  {
128
 
    if (! allowed_exts.empty())
 
133
    std::string buffered_fullpath;
 
134
    if (not allowed_exts.empty())
129
135
    {
130
136
      char *ptr= rindex(result->d_name, '.');
131
137
 
148
154
        {
149
155
          struct stat entrystat;
150
156
 
151
 
          if (result->d_name[0] == '.')
 
157
          if (result->d_name[0] == '.') // We don't pass back anything hidden at the moment.
152
158
            continue;
153
159
 
154
 
          stat(result->d_name, &entrystat);
 
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);
155
170
 
156
171
          if (S_ISDIR(entrystat.st_mode))
157
172
          {
163
178
        {
164
179
          struct stat entrystat;
165
180
 
166
 
          stat(result->d_name, &entrystat);
 
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);
167
188
 
168
189
          if (S_ISREG(entrystat.st_mode))
169
190
          {