LibCore: Return EBADF on unsupported stream operations

This commit is contained in:
Tim Schumacher 2022-12-14 14:30:58 +01:00 committed by Jelle Raaijmakers
parent e65767c2e7
commit 1ca62de558
Notes: sideshowbarker 2024-07-17 01:31:54 +09:00
6 changed files with 9 additions and 8 deletions

View file

@ -48,8 +48,7 @@ bool TarFileStream::is_eof() const
ErrorOr<size_t> TarFileStream::write(ReadonlyBytes)
{
// This is purely for wrapping and representing file contents in an archive.
VERIFY_NOT_REACHED();
return Error::from_errno(EBADF);
}
ErrorOr<NonnullOwnPtr<TarInputStream>> TarInputStream::construct(NonnullOwnPtr<Core::Stream::Stream> stream)

View file

@ -302,7 +302,7 @@ bool DeflateDecompressor::is_eof() const { return m_state == State::Idle && m_re
ErrorOr<size_t> DeflateDecompressor::write(ReadonlyBytes)
{
VERIFY_NOT_REACHED();
return Error::from_errno(EBADF);
}
bool DeflateDecompressor::is_open() const

View file

@ -183,7 +183,7 @@ bool GzipDecompressor::is_eof() const { return m_input_stream->is_eof(); }
ErrorOr<size_t> GzipDecompressor::write(ReadonlyBytes)
{
VERIFY_NOT_REACHED();
return Error::from_errno(EBADF);
}
GzipCompressor::GzipCompressor(Core::Stream::Handle<Core::Stream::Stream> stream)

View file

@ -49,7 +49,7 @@ void FixedMemoryStream::close()
ErrorOr<void> FixedMemoryStream::truncate(off_t)
{
return Error::from_errno(ENOTSUP);
return Error::from_errno(EBADF);
}
ErrorOr<Bytes> FixedMemoryStream::read(Bytes bytes)

View file

@ -729,7 +729,7 @@ ErrorOr<void> WrappedAKInputStream::discard(size_t discarded_bytes)
ErrorOr<size_t> WrappedAKInputStream::write(ReadonlyBytes)
{
VERIFY_NOT_REACHED();
return Error::from_errno(EBADF);
}
bool WrappedAKInputStream::is_eof() const
@ -753,7 +753,7 @@ WrappedAKOutputStream::WrappedAKOutputStream(NonnullOwnPtr<OutputStream> stream)
ErrorOr<Bytes> WrappedAKOutputStream::read(Bytes)
{
VERIFY_NOT_REACHED();
return Error::from_errno(EBADF);
}
ErrorOr<size_t> WrappedAKOutputStream::write(ReadonlyBytes bytes)
@ -768,7 +768,7 @@ ErrorOr<size_t> WrappedAKOutputStream::write(ReadonlyBytes bytes)
bool WrappedAKOutputStream::is_eof() const
{
VERIFY_NOT_REACHED();
return true;
}
bool WrappedAKOutputStream::is_open() const

View file

@ -70,6 +70,8 @@ private:
/// The base, abstract class for stream operations. This class defines the
/// operations one can perform on every stream in LibCore.
/// Operations without a sensible default that are unsupported by an implementation
/// of a Stream should return EBADF as an error.
class Stream {
public:
/// Reads into a buffer, with the maximum size being the size of the buffer.