Merge pull request #23 from ahesford/minimalism

Fix use of `sendfile()` on 32-bit systems
This commit is contained in:
Martchus 2023-04-06 18:06:59 +02:00 committed by GitHub
commit 59896da087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -155,7 +155,8 @@ void CopyHelper<bufferSize>::callbackCopy(NativeFileStream &input, NativeFileStr
output.flush();
const auto totalBytes = static_cast<std::streamoff>(count);
while (count) {
const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, std::min(count, bufferSize));
const auto bytesToCopy = static_cast<std::size_t>(std::min(count, static_cast<std::uint64_t>(bufferSize)));
const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, bytesToCopy);
if (bytesCopied < 0) {
throw std::ios_base::failure(argsToString("sendfile64() failed: ", std::strerror(errno)));
}