libwreport
3.6
|
open(2) file descriptors More...
#include <sys.h>
Public Member Functions | |
File (File &&)=default | |
File (const File &)=delete | |
File (const std::string &pathname) | |
Create an unopened File object for the given pathname. | |
File (const std::string &pathname, int flags, mode_t mode=0777) | |
Wrapper around open(2) | |
~File () | |
The destructor closes the file descriptor, but does not check errors on ::close(). More... | |
File & | operator= (const File &)=delete |
File & | operator= (File &&)=default |
void | open (int flags, mode_t mode=0777) |
Wrapper around open(2) | |
bool | open_ifexists (int flags, mode_t mode=0777) |
Wrap open(2) and return false instead of throwing an exception if open fails with ENOENT. | |
![]() | |
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. | |
![]() | |
FileDescriptor (FileDescriptor &&o) | |
FileDescriptor (int fd) | |
FileDescriptor (const FileDescriptor &o)=default | |
FileDescriptor & | operator= (const FileDescriptor &o)=default |
void | close () |
void | fstat (struct stat &st) |
void | fchmod (mode_t mode) |
int | dup () |
size_t | read (void *buf, size_t count) |
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) |
operator int () const | |
Static Public Member Functions | |
static File | mkstemp (const std::string &prefix) |
Additional Inherited Members | |
![]() | |
std::string | pathname |
![]() | |
int | fd = -1 |
open(2) file descriptors
wreport::sys::File::~File | ( | ) |
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 File::close() in places where it can throw safely.