dir.hh
/* dir.hh - directory access
* Copyright 2006 Bas Wijnen <wijnen@debian.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHEVEK_DIR_HH
#define SHEVEK_DIR_HH
#include <string>
#include <sys/types.h>
#include <set>
#include <glibmm.h>
namespace shevek
{
class dir
{
public:
struct file
{
std::string name;
bool is_dir;
uid_t uid;
gid_t gid;
off_t size;
bool operator< (file const &that) const;
};
typedef std::set <file> store;
typedef store::const_iterator const_iterator;
dir ();
dir (std::string const &path);
void load (std::string const &path);
const_iterator begin () const;
const_iterator end () const;
unsigned size () const;
private:
store data;
};
}
#endif
shevek::dir::file::name
std::string name
The name of the file.
Definition: dir.hh:36
shevek::dir::dir
dir()
Create an empty directory object.
shevek
Definition: args.hh:52
shevek::dir::const_iterator
store::const_iterator const_iterator
Iterator for looping over the files.
Definition: dir.hh:51
shevek::dir::load
void load(std::string const &path)
Load new content into an existing directory object.
shevek::dir
Get information about files in a directory.
Definition: dir.hh:29
shevek::dir::store
std::set< file > store
Storage of the files.
Definition: dir.hh:49
shevek::dir::file::uid
uid_t uid
The user-ID of the file.
Definition: dir.hh:40
shevek::dir::file::gid
gid_t gid
The group-ID of the file.
Definition: dir.hh:42
shevek::dir::end
const_iterator end() const
Loop over the files.
shevek::dir::file::size
off_t size
The size of the file.
Definition: dir.hh:44
shevek::dir::begin
const_iterator begin() const
Loop over the files.
shevek::dir::file::operator<
bool operator<(file const &that) const
Sorting operator, needed for putting them in a std::set.
shevek::dir::file
Information about a single file in a directory.
Definition: dir.hh:33
shevek::dir::file::is_dir
bool is_dir
Whether it is a directory.
Definition: dir.hh:38
shevek::dir::size
unsigned size() const
Number of files in the directory.