io/FileDescriptor: add method WriteAt()

This commit is contained in:
Max Kellermann 2024-08-30 10:30:03 +02:00 committed by Max Kellermann
parent 59199b5620
commit c7b80b0828
1 changed files with 7 additions and 0 deletions

View File

@ -257,6 +257,13 @@ public:
*/
void FullRead(std::span<std::byte> dest) const;
#ifndef _WIN32
[[nodiscard]]
ssize_t WriteAt(off_t offset, std::span<const std::byte> src) const noexcept {
return ::pwrite(fd, src.data(), src.size(), offset);
}
#endif
[[nodiscard]]
ssize_t Write(std::span<const std::byte> src) const noexcept {
return ::write(fd, src.data(), src.size());