diff --git a/posix/fd.cpp b/posix/fd.cpp index 0b852818..84bd5fe2 100644 --- a/posix/fd.cpp +++ b/posix/fd.cpp @@ -157,7 +157,7 @@ fd::read (void *buffer, std::size_t count) } -/////////////////////////////////////////////////////////////////////////////// +//----------------------------------------------------------------------------- ssize_t fd::write (const void *buffer, size_t count) { @@ -167,6 +167,16 @@ fd::write (const void *buffer, size_t count) } +//----------------------------------------------------------------------------- +ssize_t +fd::pwrite (const void *buf, size_t count, size_t offset) +{ + return error::try_value ( + ::pwrite (native (), buf, count, offset) + ); +} + + /////////////////////////////////////////////////////////////////////////////// off_t fd::lseek (off_t offset, int whence) diff --git a/posix/fd.hpp b/posix/fd.hpp index 73e4c7cf..ceccb7d5 100644 --- a/posix/fd.hpp +++ b/posix/fd.hpp @@ -68,47 +68,7 @@ namespace cruft::posix { //--------------------------------------------------------------------- [[nodiscard]] ssize_t read (void *buf, size_t count); [[nodiscard]] ssize_t write (const void *buf, size_t count); - - - //--------------------------------------------------------------------- - template - [[nodiscard]] - ValueT* - read (cruft::view dst) - { - return dst.begin () + read ( - &*std::data (dst), std::size (dst) * sizeof (ValueT) - ); - } - - - //--------------------------------------------------------------------- - template - [[nodiscard]] - auto - write (const cruft::view &src) - { - return const_cast ( - write ( - cruft::view (src) - ) - ); - } - - - //--------------------------------------------------------------------- - template - [[nodiscard]] - const ValueT* - write (const cruft::view &src) - { - const auto written = write ( - &*std::data (src), std::size (src) * sizeof (ValueT) - ); - - CHECK_MOD (written, sizeof (ValueT)); - return src.begin () + written / sizeof (ValueT); - } + [[nodiscard]] ssize_t pwrite (const void *buf, size_t count, size_t offset); //---------------------------------------------------------------------