|
libwreport
3.29
|
Wrap a path on the file system opened with O_PATH. More...
#include <sys.h>
Data Structures | |
| struct | iterator |
| Iterator for directory entries. More... | |
Public Member Functions | |
| Path (const char *pathname, int flags=0, mode_t mode=0777) | |
| Open the given pathname with flags | O_PATH. | |
| Path (const std::string &pathname, int flags=0, mode_t mode=0777) | |
| Open the given pathname with flags | O_PATH. | |
| Path (Path &parent, const char *pathname, int flags=0, mode_t mode=0777) | |
| Open the given pathname calling parent.openat, with flags | O_PATH. | |
| Path (const Path &)=delete | |
| Path (Path &&)=default | |
| Path & | operator= (const Path &)=delete |
| Path & | operator= (Path &&)=default |
| void | open (int flags, mode_t mode=0777) |
| Wrapper around open(2) with flags | O_PATH. | |
| DIR * | fdopendir () |
| iterator | begin () |
| Begin iterator on all directory entries. | |
| iterator | end () |
| End iterator on all directory entries. | |
| int | openat (const char *pathname, int flags, mode_t mode=0777) |
| int | openat_ifexists (const char *pathname, int flags, mode_t mode=0777) |
| Same as openat, but returns -1 if the file does not exist. | |
| bool | faccessat (const char *pathname, int mode, int flags=0) |
| void | fstatat (const char *pathname, struct stat &st) |
| bool | fstatat_ifexists (const char *pathname, struct stat &st) |
| fstatat, but in case of ENOENT returns false instead of throwing | |
| void | lstatat (const char *pathname, struct stat &st) |
| fstatat with the AT_SYMLINK_NOFOLLOW flag set | |
| bool | lstatat_ifexists (const char *pathname, struct stat &st) |
| lstatat, but in case of ENOENT returns false instead of throwing | |
| void | unlinkat (const char *pathname) |
| void | mkdirat (const char *pathname, mode_t mode=0777) |
| void | rmdirat (const char *pathname) |
| unlinkat with the AT_REMOVEDIR flag set | |
| void | symlinkat (const char *target, const char *linkpath) |
| std::string | readlinkat (const char *pathname) |
| void | rmtree () |
| Delete the directory pointed to by this Path, with all its contents. More... | |
| ManagedNamedFileDescriptor (ManagedNamedFileDescriptor &&)=default | |
| ManagedNamedFileDescriptor (const ManagedNamedFileDescriptor &)=delete | |
Public Member Functions inherited from wreport::sys::ManagedNamedFileDescriptor | |
| ManagedNamedFileDescriptor (ManagedNamedFileDescriptor &&)=default | |
| ManagedNamedFileDescriptor (const ManagedNamedFileDescriptor &)=delete | |
| ~ManagedNamedFileDescriptor () | |
| The destructor closes the file descriptor, but does not check errors on ::close(). More... | |
| ManagedNamedFileDescriptor & | operator= (const ManagedNamedFileDescriptor &)=delete |
| ManagedNamedFileDescriptor & | operator= (ManagedNamedFileDescriptor &&) |
| NamedFileDescriptor (int fd, const std::string &pathname) | |
| NamedFileDescriptor (NamedFileDescriptor &&) | |
| NamedFileDescriptor (const NamedFileDescriptor &o)=default | |
Public Member Functions inherited from wreport::sys::NamedFileDescriptor | |
| NamedFileDescriptor (int fd, const std::string &pathname) | |
| NamedFileDescriptor (NamedFileDescriptor &&) | |
| NamedFileDescriptor & | operator= (NamedFileDescriptor &&) |
| NamedFileDescriptor (const NamedFileDescriptor &o)=default | |
| NamedFileDescriptor & | operator= (const NamedFileDescriptor &o)=default |
| virtual void | throw_error (const char *desc) |
| Throw an exception based on errno and the given message. More... | |
| virtual void | throw_runtime_error (const char *desc) |
| Throw a runtime_error unrelated from errno. More... | |
| const std::string & | name () const |
| Return the file pathname. | |
Public Member Functions inherited from wreport::sys::FileDescriptor | |
| FileDescriptor (FileDescriptor &&o) | |
| FileDescriptor (int fd) | |
| FileDescriptor (const FileDescriptor &o)=default | |
| FileDescriptor & | operator= (const FileDescriptor &o)=default |
| bool | is_open () const |
| Check if the file descriptor is open (that is, if it is not -1) | |
| void | close () |
| Close the file descriptor, setting its value to -1. More... | |
| void | fstat (struct stat &st) |
| void | fchmod (mode_t mode) |
| void | futimens (const struct ::timespec ts[2]) |
| void | fsync () |
| void | fdatasync () |
| int | dup () |
| size_t | read (void *buf, size_t count) |
| bool | read_all_or_retry (void *buf, size_t count) |
Read count bytes into bufr, retrying partial reads, stopping at EOF. More... | |
| void | read_all_or_throw (void *buf, size_t count) |
| Read all the data into buf, throwing runtime_error in case of a partial read. | |
| size_t | write (const void *buf, size_t count) |
| template<typename Container > | |
| size_t | write (const Container &c) |
| void | write_all_or_retry (const void *buf, size_t count) |
| Write all the data in buf, retrying partial writes. | |
| template<typename Container > | |
| void | write_all_or_retry (const Container &c) |
| void | write_all_or_throw (const void *buf, size_t count) |
| Write all the data in buf, throwing runtime_error in case of a partial write. | |
| template<typename Container > | |
| void | write_all_or_throw (const Container &c) |
| off_t | lseek (off_t offset, int whence=SEEK_SET) |
| size_t | pread (void *buf, size_t count, off_t offset) |
| size_t | pwrite (const void *buf, size_t count, off_t offset) |
| template<typename Container > | |
| size_t | pwrite (const Container &c, off_t offset) |
| void | ftruncate (off_t length) |
| MMap | mmap (size_t length, int prot, int flags, off_t offset=0) |
| bool | ofd_setlk (struct ::flock &) |
| Open file description locks F_OFD_SETLK operation. More... | |
| bool | ofd_setlkw (struct ::flock &, bool retry_on_signal=true) |
| Open file description locks F_OFD_SETLKW operation. More... | |
| bool | ofd_getlk (struct ::flock &) |
| Open file description locks F_OFD_GETLK operation. More... | |
| void | sendfile (FileDescriptor &out_fd, off_t offset, size_t count) |
| Call sendfile with this file as in_fd, falling back on write if it is not available. More... | |
| int | getfl () |
| Get open flags for the file. | |
| void | setfl (int flags) |
| Set open flags for the file. | |
| operator int () const | |
Static Public Member Functions | |
| static std::string | mkdtemp (const std::string &prefix) |
| static std::string | mkdtemp (const char *prefix) |
| static std::string | mkdtemp (char *pathname_template) |
Additional Inherited Members | |
Protected Attributes inherited from wreport::sys::NamedFileDescriptor | |
| std::string | pathname |
Protected Attributes inherited from wreport::sys::FileDescriptor | |
| int | fd = -1 |
Wrap a path on the file system opened with O_PATH.
| void wreport::sys::Path::rmtree | ( | ) |
Delete the directory pointed to by this Path, with all its contents.
The path must point to a directory.