libept
|
Wrap a path on the file system opened with O_PATH. More...
#include <sys.h>
Classes | |
struct | iterator |
Iterator for directory entries. More... | |
Public Member Functions | |
Path (const char *pathname, int flags=0) | |
Open the given pathname with flags | O_PATH. More... | |
Path (const std::string &pathname, int flags=0) | |
Open the given pathname with flags | O_PATH. More... | |
Path (Path &parent, const char *pathname, int flags=0) | |
Open the given pathname calling parent.openat, with flags | O_PATH. More... | |
Path (const Path &)=delete | |
Path (Path &&)=default | |
Path & | operator= (const Path &)=delete |
Path & | operator= (Path &&)=default |
~Path () | |
The destructor closes the file descriptor, but does not check errors on ::close(). More... | |
DIR * | fdopendir () |
iterator | begin () |
Begin iterator on all directory entries. More... | |
iterator | end () |
End iterator on all directory entries. More... | |
int | openat (const char *pathname, int flags, mode_t mode=0777) |
void | fstatat (const char *pathname, struct stat &st) |
void | lstatat (const char *pathname, struct stat &st) |
fstatat with the AT_SYMLINK_NOFOLLOW flag set More... | |
void | unlinkat (const char *pathname) |
void | rmdirat (const char *pathname) |
unlinkat with the AT_REMOVEDIR flag set More... | |
void | rmtree () |
Delete the directory pointed to by this Path, with all its contents. More... | |
![]() | |
NamedFileDescriptor (int fd, const std::string &pathname) | |
NamedFileDescriptor (NamedFileDescriptor &&) | |
NamedFileDescriptor & | operator= (NamedFileDescriptor &&) |
virtual void | throw_error (const char *desc) |
Throw an exception based on errno and the given message. More... | |
const std::string & | name () const |
Return the file pathname. More... | |
![]() | |
FileDescriptor () | |
FileDescriptor (FileDescriptor &&o) | |
FileDescriptor (int fd) | |
virtual | ~FileDescriptor () |
void | close () |
void | fstat (struct stat &st) |
void | fchmod (mode_t mode) |
size_t | write (const void *buf, size_t count) |
void | write_all (const void *buf, size_t count) |
Write all the data in buf, retrying partial writes. More... | |
MMap | mmap (size_t length, int prot, int flags, off_t offset=0) |
operator int () const | |
Additional Inherited Members | |
![]() | |
std::string | pathname |
![]() | |
int | fd = -1 |
Wrap a path on the file system opened with O_PATH.
ept::sys::Path::Path | ( | const char * | pathname, |
int | flags = 0 |
||
) |
Open the given pathname with flags | O_PATH.
References ept::sys::FileDescriptor::fd, O_PATH, and ept::sys::NamedFileDescriptor::throw_error().
ept::sys::Path::Path | ( | const std::string & | pathname, |
int | flags = 0 |
||
) |
Open the given pathname with flags | O_PATH.
References ept::sys::FileDescriptor::fd, O_PATH, and ept::sys::NamedFileDescriptor::throw_error().
ept::sys::Path::Path | ( | Path & | parent, |
const char * | pathname, | ||
int | flags = 0 |
||
) |
Open the given pathname calling parent.openat, with flags | O_PATH.
|
delete |
|
default |
ept::sys::Path::~Path | ( | ) |
The destructor closes the file descriptor, but does not check errors on ::close().
In normal program flow, it is a good idea to explicitly call Path::close() in places where it can throw safely.
References ept::sys::FileDescriptor::close(), and ept::sys::FileDescriptor::fd.
Path::iterator ept::sys::Path::begin | ( | ) |
Begin iterator on all directory entries.
References ept::sys::FileDescriptor::fd.
Referenced by rmtree().
Path::iterator ept::sys::Path::end | ( | ) |
End iterator on all directory entries.
Referenced by rmtree().
DIR * ept::sys::Path::fdopendir | ( | ) |
References ept::sys::FileDescriptor::fd, openat(), res, and ept::sys::NamedFileDescriptor::throw_error().
Referenced by ept::sys::Path::iterator::iterator().
void ept::sys::Path::fstatat | ( | const char * | pathname, |
struct stat & | st | ||
) |
References ept::sys::FileDescriptor::fd, and ept::sys::NamedFileDescriptor::throw_error().
Referenced by ept::sys::Path::iterator::isblk(), ept::sys::Path::iterator::ischr(), ept::sys::Path::iterator::isdir(), ept::sys::Path::iterator::isfifo(), ept::sys::Path::iterator::islnk(), ept::sys::Path::iterator::isreg(), ept::sys::Path::iterator::issock(), and lstatat().
void ept::sys::Path::lstatat | ( | const char * | pathname, |
struct stat & | st | ||
) |
fstatat with the AT_SYMLINK_NOFOLLOW flag set
References ept::sys::FileDescriptor::fd, fstatat(), and ept::sys::NamedFileDescriptor::throw_error().
int ept::sys::Path::openat | ( | const char * | pathname, |
int | flags, | ||
mode_t | mode = 0777 |
||
) |
References ept::sys::FileDescriptor::fd, res, and ept::sys::NamedFileDescriptor::throw_error().
Referenced by fdopendir().
void ept::sys::Path::rmdirat | ( | const char * | pathname | ) |
unlinkat with the AT_REMOVEDIR flag set
References ept::sys::FileDescriptor::fd, ept::sys::NamedFileDescriptor::throw_error(), and unlinkat().
void ept::sys::Path::rmtree | ( | ) |
Delete the directory pointed to by this Path, with all its contents.
The path must point to a directory.
References begin(), end(), ept::sys::NamedFileDescriptor::name(), ept::sys::rmdir(), rmtree(), and unlinkat().
Referenced by rmtree(), and ept::sys::rmtree().
void ept::sys::Path::unlinkat | ( | const char * | pathname | ) |
References ept::sys::FileDescriptor::fd, and ept::sys::NamedFileDescriptor::throw_error().