From c7b80b08287fec2d3d0deddcb3369c96a4455d45 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 30 Aug 2024 10:30:03 +0200 Subject: [PATCH] io/FileDescriptor: add method WriteAt() --- src/io/FileDescriptor.hxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/io/FileDescriptor.hxx b/src/io/FileDescriptor.hxx index e31217e9a..c132a4e9c 100644 --- a/src/io/FileDescriptor.hxx +++ b/src/io/FileDescriptor.hxx @@ -257,6 +257,13 @@ public: */ void FullRead(std::span dest) const; +#ifndef _WIN32 + [[nodiscard]] + ssize_t WriteAt(off_t offset, std::span src) const noexcept { + return ::pwrite(fd, src.data(), src.size(), offset); + } +#endif + [[nodiscard]] ssize_t Write(std::span src) const noexcept { return ::write(fd, src.data(), src.size());