summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Directory.cc21
-rw-r--r--src/FbTk/Directory.hh7
2 files changed, 25 insertions, 3 deletions
diff --git a/src/FbTk/Directory.cc b/src/FbTk/Directory.cc
index 8d327dd..5ec5c0c 100644
--- a/src/FbTk/Directory.cc
+++ b/src/FbTk/Directory.cc
@@ -19,10 +19,13 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Directory.cc,v 1.1 2003/05/18 22:06:59 fluxgen Exp $ 22// $Id: Directory.cc,v 1.2 2003/08/17 13:19:54 fluxgen Exp $
23 23
24#include "Directory.hh" 24#include "Directory.hh"
25 25
26#include <sys/stat.h>
27#include <unistd.h>
28
26namespace FbTk { 29namespace FbTk {
27 30
28Directory::Directory(const char *dir):m_dir(0), 31Directory::Directory(const char *dir):m_dir(0),
@@ -83,4 +86,20 @@ bool Directory::open(const char *dir) {
83 return true; 86 return true;
84} 87}
85 88
89bool Directory::isDirectory(const std::string &filename) {
90 struct stat statbuf;
91 if (stat(filename.c_str(), &statbuf) != 0)
92 return false;
93
94 return S_ISDIR(statbuf.st_mode);
95}
96
97bool Directory::isRegularFile(const std::string &filename) {
98 struct stat statbuf;
99 if (stat(filename.c_str(), &statbuf) != 0)
100 return false;
101
102 return S_ISREG(statbuf.st_mode);
103}
104
86}; // end namespace FbTk 105}; // end namespace FbTk
diff --git a/src/FbTk/Directory.hh b/src/FbTk/Directory.hh
index 0786214..7862a51 100644
--- a/src/FbTk/Directory.hh
+++ b/src/FbTk/Directory.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Directory.hh,v 1.1 2003/05/18 22:06:59 fluxgen Exp $ 22// $Id: Directory.hh,v 1.2 2003/08/17 13:19:54 fluxgen Exp $
23 23
24#ifndef FBTK_DIRECTORY_HH 24#ifndef FBTK_DIRECTORY_HH
25#define FBTK_DIRECTORY_HH 25#define FBTK_DIRECTORY_HH
@@ -51,7 +51,10 @@ public:
51 bool open(const char *dir); 51 bool open(const char *dir);
52 /// @return number of entries in the directory 52 /// @return number of entries in the directory
53 size_t entries() const { return m_num_entries; } 53 size_t entries() const { return m_num_entries; }
54 54 /// @return true if file is a directory
55 static bool isDirectory(const std::string &filename);
56 /// @return true if a file is a regular file
57 static bool isRegularFile(const std::string &filename);
55private: 58private:
56 DIR *m_dir; 59 DIR *m_dir;
57 size_t m_num_entries; ///< number of file entries in directory 60 size_t m_num_entries; ///< number of file entries in directory