mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:27:35 +00:00
AK: Remove the deprecated Stream implementation :^)
This commit is contained in:
parent
63b11030f0
commit
e8d5e938de
11 changed files with 1 additions and 708 deletions
|
@ -589,155 +589,4 @@ ErrorOr<int> LocalSocket::release_fd()
|
|||
return fd;
|
||||
}
|
||||
|
||||
WrappedAKInputStream::WrappedAKInputStream(NonnullOwnPtr<DeprecatedInputStream> stream)
|
||||
: m_stream(move(stream))
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<Bytes> WrappedAKInputStream::read(Bytes bytes)
|
||||
{
|
||||
auto bytes_read = m_stream->read(bytes);
|
||||
|
||||
if (m_stream->has_any_error())
|
||||
return Error::from_string_literal("Underlying InputStream indicated an error");
|
||||
|
||||
return bytes.slice(0, bytes_read);
|
||||
}
|
||||
|
||||
ErrorOr<void> WrappedAKInputStream::discard(size_t discarded_bytes)
|
||||
{
|
||||
if (!m_stream->discard_or_error(discarded_bytes))
|
||||
return Error::from_string_literal("Underlying InputStream indicated an error");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<size_t> WrappedAKInputStream::write(ReadonlyBytes)
|
||||
{
|
||||
return Error::from_errno(EBADF);
|
||||
}
|
||||
|
||||
bool WrappedAKInputStream::is_eof() const
|
||||
{
|
||||
return m_stream->unreliable_eof();
|
||||
}
|
||||
|
||||
bool WrappedAKInputStream::is_open() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void WrappedAKInputStream::close()
|
||||
{
|
||||
}
|
||||
|
||||
WrappedAKOutputStream::WrappedAKOutputStream(NonnullOwnPtr<DeprecatedOutputStream> stream)
|
||||
: m_stream(move(stream))
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<Bytes> WrappedAKOutputStream::read(Bytes)
|
||||
{
|
||||
return Error::from_errno(EBADF);
|
||||
}
|
||||
|
||||
ErrorOr<size_t> WrappedAKOutputStream::write(ReadonlyBytes bytes)
|
||||
{
|
||||
auto bytes_written = m_stream->write(bytes);
|
||||
|
||||
if (m_stream->has_any_error())
|
||||
return Error::from_string_literal("Underlying OutputStream indicated an error");
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
bool WrappedAKOutputStream::is_eof() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WrappedAKOutputStream::is_open() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void WrappedAKOutputStream::close()
|
||||
{
|
||||
}
|
||||
|
||||
WrapInAKInputStream::WrapInAKInputStream(AK::Stream& stream)
|
||||
: m_stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
size_t WrapInAKInputStream::read(Bytes bytes)
|
||||
{
|
||||
if (has_any_error())
|
||||
return 0;
|
||||
|
||||
auto data_or_error = m_stream.read(bytes);
|
||||
if (data_or_error.is_error()) {
|
||||
set_fatal_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return data_or_error.value().size();
|
||||
}
|
||||
|
||||
bool WrapInAKInputStream::unreliable_eof() const
|
||||
{
|
||||
return m_stream.is_eof();
|
||||
}
|
||||
|
||||
bool WrapInAKInputStream::read_or_error(Bytes bytes)
|
||||
{
|
||||
if (read(bytes) < bytes.size()) {
|
||||
set_fatal_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WrapInAKInputStream::discard_or_error(size_t count)
|
||||
{
|
||||
auto maybe_error = m_stream.discard(count);
|
||||
|
||||
if (maybe_error.is_error()) {
|
||||
set_fatal_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
WrapInAKOutputStream::WrapInAKOutputStream(AK::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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/Badge.h>
|
||||
#include <AK/BufferedStream.h>
|
||||
#include <AK/CircularBuffer.h>
|
||||
#include <AK/DeprecatedStream.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Function.h>
|
||||
|
@ -608,57 +607,4 @@ private:
|
|||
using ReusableTCPSocket = BasicReusableSocket<TCPSocket>;
|
||||
using ReusableUDPSocket = BasicReusableSocket<UDPSocket>;
|
||||
|
||||
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
|
||||
class WrappedAKInputStream final : public AK::Stream {
|
||||
public:
|
||||
WrappedAKInputStream(NonnullOwnPtr<DeprecatedInputStream> stream);
|
||||
virtual ErrorOr<Bytes> read(Bytes) override;
|
||||
virtual ErrorOr<void> discard(size_t discarded_bytes) override;
|
||||
virtual ErrorOr<size_t> write(ReadonlyBytes) override;
|
||||
virtual bool is_eof() const override;
|
||||
virtual bool is_open() const override;
|
||||
virtual void close() override;
|
||||
|
||||
private:
|
||||
NonnullOwnPtr<DeprecatedInputStream> m_stream;
|
||||
};
|
||||
|
||||
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
|
||||
class WrappedAKOutputStream final : public AK::Stream {
|
||||
public:
|
||||
WrappedAKOutputStream(NonnullOwnPtr<DeprecatedOutputStream> stream);
|
||||
virtual ErrorOr<Bytes> read(Bytes) override;
|
||||
virtual ErrorOr<size_t> write(ReadonlyBytes) override;
|
||||
virtual bool is_eof() const override;
|
||||
virtual bool is_open() const override;
|
||||
virtual void close() override;
|
||||
|
||||
private:
|
||||
NonnullOwnPtr<DeprecatedOutputStream> m_stream;
|
||||
};
|
||||
|
||||
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
|
||||
class WrapInAKInputStream final : public DeprecatedInputStream {
|
||||
public:
|
||||
WrapInAKInputStream(AK::Stream& stream);
|
||||
virtual size_t read(Bytes) override;
|
||||
virtual bool unreliable_eof() const override;
|
||||
virtual bool read_or_error(Bytes) override;
|
||||
virtual bool discard_or_error(size_t count) override;
|
||||
|
||||
private:
|
||||
AK::Stream& m_stream;
|
||||
};
|
||||
|
||||
// Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
|
||||
class WrapInAKOutputStream final : public DeprecatedOutputStream {
|
||||
public:
|
||||
WrapInAKOutputStream(AK::Stream& stream);
|
||||
virtual size_t write(ReadonlyBytes) override;
|
||||
virtual bool write_or_error(ReadonlyBytes) override;
|
||||
|
||||
private:
|
||||
AK::Stream& m_stream;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedMemoryStream.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Memory.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue