19 #include <foxxll/config.hpp> 31 std::unique_lock<std::mutex> fd_lock(
fd_mutex_);
33 auto* cbuffer =
static_cast<char*
>(buffer);
40 off_t rc = ::lseek(
file_des_, offset, SEEK_SET);
46 " call=::lseek(fd,offset,SEEK_SET)" <<
49 " offset=" << offset <<
50 " buffer=" << static_cast<void*>(cbuffer) <<
61 if ((rc = ::read(
file_des_, cbuffer, (
unsigned int)bytes)) <= 0)
63 if ((rc = ::read(
file_des_, cbuffer, bytes)) <= 0)
69 " call=::read(fd,buffer,bytes)" <<
72 " offset=" << offset <<
73 " buffer=" << static_cast<void*>(buffer) <<
79 bytes =
static_cast<size_type>(bytes - rc);
83 if (bytes > 0 && offset == this->
_size())
87 memset(cbuffer, 0, bytes);
95 if ((rc = ::write(
file_des_, cbuffer, (
unsigned int)bytes)) <= 0)
97 if ((rc = ::write(
file_des_, cbuffer, bytes)) <= 0)
103 " call=::write(fd,buffer,bytes)" <<
106 " offset=" << offset <<
107 " buffer=" << static_cast<void*>(buffer) <<
108 " bytes=" << bytes <<
113 bytes =
static_cast<size_type>(bytes - rc);
const char * io_type() const final
static uint_pair max()
return an uint_pair instance containing the largest value possible
request::offset_type offset_type
the offset of a request, also the size of the file
request::size_type size_type
the size of a request
void serve(void *buffer, offset_type offset, size_type bytes, request::read_or_write op) final
#define FOXXLL_THROW_ERRNO(exception_type, error_message)
Throws exception_type with "Error in [function] : [error_message] : [errno message]".
static const size_t bytes
number of bytes in uint_pair
const std::string filename_