00001 #ifndef BUFFY_SYSTEM_H
00002 #define BUFFY_SYSTEM_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <sys/stat.h>
00025 #include <sys/types.h>
00026 #include <dirent.h>
00027 #include <string>
00028 #include <set>
00029
00030 namespace buffy {
00031
00032 class Directory
00033 {
00034 DIR* dir;
00035
00036 public:
00037 Directory(const std::string& name);
00038 ~Directory() { closedir(dir); }
00039 struct dirent* read() { return readdir(dir); }
00040 };
00041
00042 class InodeSet : protected std::set<ino_t>
00043 {
00044 public:
00045 InodeSet() {}
00046 InodeSet(const InodeSet& is) : std::set<ino_t>(is) {}
00047 InodeSet(ino_t inode) { insert(inode); }
00048 InodeSet operator+(ino_t inode) { InodeSet res(*this); res.add(inode); return res; }
00049 InodeSet& operator+=(ino_t inode) { add(inode); return *this; }
00050 void add(ino_t inode) { insert(inode); }
00051 bool has(ino_t inode) { return find(inode) != end(); }
00052 };
00053
00057 void stat(const std::string& name, struct stat* st);
00058
00067 bool statIfFound(const std::string& name, struct stat* st);
00068
00069 }
00070
00071
00072 #endif