1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
* Implementation of CachedDirectory class.
28
#include "cached_directory.h"
33
CachedDirectory::CachedDirectory(const string &in_path)
39
CachedDirectory::~CachedDirectory()
41
Entries::iterator p= entries.begin();
42
while (p != entries.end())
50
bool CachedDirectory::open(const string &in_path)
55
if ((dirp= opendir(in_path.c_str())) == NULL)
62
* The readdir_r() call on Solaris operates a bit differently from other
63
* systems in that the dirent structure must be allocated along with enough
64
* space to contain the filename (see man page for readdir_r on Solaris).
68
size= sizeof(dirent) + pathconf(in_path.c_str(), _PC_NAME_MAX);
73
dirent *entry= (dirent *) malloc(size);
85
retcode= readdir_r(dirp, entry, &result);
86
while ((retcode == 0) && (result != NULL))
88
entries.push_back(new Entry(entry->d_name));
89
retcode= readdir_r(dirp, entry, &result);