libwreport  3.5
Public Member Functions | Protected Attributes
wreport::sys::FileDescriptor Class Reference

Common operations on file descriptors. More...

#include <sys.h>

Inheritance diagram for wreport::sys::FileDescriptor:
wreport::sys::NamedFileDescriptor wreport::sys::File wreport::sys::Path

Public Member Functions

 FileDescriptor (FileDescriptor &&o)
 
 FileDescriptor (int fd)
 
virtual void throw_error (const char *desc)
 Throw an exception based on errno and the given message. More...
 
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.
 
MMap mmap (size_t length, int prot, int flags, off_t offset=0)
 
 operator int () const
 

Protected Attributes

int fd = -1
 

Detailed Description

Common operations on file descriptors.

Except when documented otherwise, methods of this class are just thin wrappers around the libc functions with the same name, that check error results and throw exceptions if the functions failed.

Implementing what to do on construction and destruction is left to the subclassers: at the FileDescriptor level, the destructor does nothing and leaves the file descriptor open.

Member Function Documentation

virtual void wreport::sys::FileDescriptor::throw_error ( const char *  desc)
virtual

Throw an exception based on errno and the given message.

This can be overridden by subclasses that may have more information about the file descriptor, so that they can generate more descriptive messages.

Reimplemented in wreport::sys::NamedFileDescriptor.


The documentation for this class was generated from the following file: