io/FileDescriptor: add readv()/writev() wrappers
This commit is contained in:
parent
fc4a579d83
commit
6dce8dcaa5
|
@ -13,6 +13,7 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#include <sys/uio.h> // for struct iovec
|
||||
#endif
|
||||
|
||||
#ifndef O_NOCTTY
|
||||
|
@ -295,6 +296,18 @@ FileDescriptor::FullWrite(std::span<const std::byte> src) const
|
|||
|
||||
#ifndef _WIN32
|
||||
|
||||
ssize_t
|
||||
FileDescriptor::Read(std::span<const struct iovec> v) const noexcept
|
||||
{
|
||||
return readv(fd, v.data(), v.size());
|
||||
}
|
||||
|
||||
ssize_t
|
||||
FileDescriptor::Write(std::span<const struct iovec> v) const noexcept
|
||||
{
|
||||
return writev(fd, v.data(), v.size());
|
||||
}
|
||||
|
||||
int
|
||||
FileDescriptor::Poll(short events, int timeout) const noexcept
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
struct iovec;
|
||||
class UniqueFileDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -271,6 +272,18 @@ public:
|
|||
void FullWrite(std::span<const std::byte> src) const;
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
* Wrapper for readv().
|
||||
*/
|
||||
[[nodiscard]]
|
||||
ssize_t Read(std::span<const struct iovec> v) const noexcept;
|
||||
|
||||
/**
|
||||
* Wrapper for writev().
|
||||
*/
|
||||
[[nodiscard]]
|
||||
ssize_t Write(std::span<const struct iovec> v) const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
int Poll(short events, int timeout) const noexcept;
|
||||
|
||||
|
|
Loading…
Reference in New Issue