mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibCore: Add Stream::WrapInAKOutputStream
This commit is contained in:
parent
bd65ecf05c
commit
dd948b046c
2 changed files with 40 additions and 0 deletions
|
@ -830,4 +830,33 @@ bool WrapInAKInputStream::discard_or_error(size_t count)
|
|||
return true;
|
||||
}
|
||||
|
||||
WrapInAKOutputStream::WrapInAKOutputStream(Core::Stream::Stream& stream)
|
||||
: m_stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
size_t WrapInAKOutputStream::write(ReadonlyBytes bytes)
|
||||
{
|
||||
if (has_any_error())
|
||||
return 0;
|
||||
|
||||
auto length_or_error = m_stream.write(bytes);
|
||||
if (length_or_error.is_error()) {
|
||||
set_fatal_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return length_or_error.value();
|
||||
}
|
||||
|
||||
bool WrapInAKOutputStream::write_or_error(ReadonlyBytes bytes)
|
||||
{
|
||||
if (write(bytes) < bytes.size()) {
|
||||
set_fatal_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue