System.h

Go to the documentation of this file.
00001 #ifndef BUFFY_SYSTEM_H
00002 #define BUFFY_SYSTEM_H
00003 
00004 /*
00005  * Commodity wrappers for system functions
00006  *
00007  * Copyright (C) 2003,2004,2005,2006  Enrico Zini <enrico@debian.org>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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 // vim:set ts=4 sw=4:
00072 #endif

Generated on Mon Sep 24 05:36:17 2007 for libbuffy by  doxygen 1.5.3