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
* Defines the interface to the CachedDirectory class.
28
#ifndef MYSYS_CACHED_DIRECTORY_H
29
#define MYSYS_CACHED_DIRECTORY_H
39
* A utility class to handle processing the entries/files within a directory.
41
* This class will allow the user to either get a list of the entry names
42
* within a given directory.
51
Entry(std::string in_name)
55
typedef std::vector<Entry *> Entries;
57
int error; ///< Error code stored from various syscalls
58
Entries entries; ///< Entries in the directory
61
* Encapsulate the logic to open the directory.
62
* @param[in] dirPath The path to the directory to open and read.
63
* @retval true Success
64
* @retval false Failure
66
bool open(const std::string &dirPath);
69
explicit CachedDirectory()
74
* Constructor taking full directory path as sole parameter.
76
* @param[in] Path to the directory to open
78
CachedDirectory(const std::string &in_path);
80
* Destructor. Cleans up any resources we've taken
85
* Returns whether the CachedDirectory object is in a failed state
87
inline bool fail() const
93
* Returns the stored error code of the last action the directory
94
* object took (open, read, etc)
96
inline int getError() const
102
* Return the list of entries read from the directory
105
* A vector of strings containing the directory entry names.
107
inline const Entries &getEntries()
113
#endif /* MYSYS_CACHED_DIRECTORY_H */