~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cached_directory.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

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