posix/fd: add read and write member functions
This commit is contained in:
parent
cf7fda382a
commit
4196702b38
21
posix/fd.cpp
21
posix/fd.cpp
@ -96,6 +96,27 @@ fd::stat (void) const
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
ssize_t
|
||||
fd::read (void *buffer, size_t count)
|
||||
{
|
||||
auto res = ::read (m_fd, buffer, count);
|
||||
if (res == -1)
|
||||
errno_error::throw_code ();
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ssize_t
|
||||
fd::write (const void *buffer, size_t count)
|
||||
{
|
||||
auto res = ::write (m_fd, buffer, count);
|
||||
if (res == -1)
|
||||
errno_error::throw_code ();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
fd::operator int (void) const
|
||||
{
|
||||
|
@ -53,6 +53,10 @@ namespace util::posix {
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
struct ::stat stat (void) const;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
ssize_t read ( void *buf, size_t count);
|
||||
ssize_t write (const void *buf, size_t count);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
operator int (void) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user