1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:57:44 +00:00

AK: Enable Core::File to switch blocking-mode during use

This closely mirrors Socket::set_blocking. Note that it does not make
sense to make this a virtual method on a base class, since
SeekableStream and FixedMemoryStream cannot possible be anything except
than blocking.
This commit is contained in:
Ben Wiederhake 2023-05-21 22:24:58 +02:00 committed by Andreas Kling
parent 6f8c2dc322
commit 62ebb78433
2 changed files with 16 additions and 0 deletions

View file

@ -68,6 +68,13 @@ public:
virtual ErrorOr<size_t> seek(i64 offset, SeekMode) override;
virtual ErrorOr<void> truncate(size_t length) override;
// Sets the blocking mode of the file. If blocking mode is disabled, reads
// will fail with EAGAIN when there's no data available to read, and writes
// will fail with EAGAIN when the data cannot be written without blocking
// (due to the send buffer being full, for example).
// See also Socket::set_blocking.
ErrorOr<void> set_blocking(bool enabled);
template<OneOf<::IPC::File, ::Core::MappedFile> VIP>
int leak_fd(Badge<VIP>)
{