/usr/include/wreport/internals/fs.h is in libwreport-dev 3.6-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #ifndef WREPORT_INTERNALS_FS_H
#define WREPORT_INTERNALS_FS_H
#include <string>
#include <iterator>
#include <dirent.h>
#include <sys/stat.h>
namespace wreport {
namespace fs {
/**
* Access a directory on the file system
*/
struct Directory
{
/// Pathname of the directory
const std::string& pathname;
/**
* O_PATH file descriptor pointing at the directory, or -1 if the
* directory does not exist
*/
int fd;
/**
* Iterator for directory entries
*/
struct const_iterator : public std::iterator<std::input_iterator_tag, struct dirent>
{
DIR* dir = 0;
struct dirent* cur_entry = 0;
// End iterator
const_iterator();
// Start iteration on dir
const_iterator(const Directory& dir);
const_iterator(const const_iterator&) = delete;
const_iterator(const_iterator&& o)
: dir(o.dir), cur_entry(o.cur_entry)
{
o.dir = nullptr;
o.cur_entry = nullptr;
}
~const_iterator();
const_iterator& operator=(const const_iterator&) = delete;
const_iterator& operator=(const_iterator&&) = delete;
bool operator==(const const_iterator& i) const;
bool operator!=(const const_iterator& i) const;
struct dirent& operator*() const { return *cur_entry; }
struct dirent* operator->() const { return cur_entry; }
void operator++();
};
Directory(const std::string& pathname);
~Directory();
/// Begin iterator on all directory entries
const_iterator begin() const { return const_iterator(*this); }
/// End iterator on all directory entries
const_iterator end() const { return const_iterator(); }
/// Check if the directory exists
bool exists() const { return fd != -1; }
/// Call stat(2) on the directory
void stat(struct stat& st);
};
}
}
#endif
|