Truly independent web browser
AK: Remove unused ConstrainedStream
Andreas Klingd69533162c59
diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txtindex 2b39acc1154..1bb85b6d95a 100644--- a/AK/CMakeLists.txt+++ b/AK/CMakeLists.txt@@ -4,7 +4,6 @@ set(SOURCESByteString.cppByteStringImpl.cppCircularBuffer.cpp- ConstrainedStream.cppCountingStream.cppDemangle.cppError.cppdiff --git a/AK/ConstrainedStream.cpp b/AK/ConstrainedStream.cppdeleted file mode 100644index 31d1f520d58..00000000000--- a/AK/ConstrainedStream.cpp+++ /dev/null@@ -1,50 +0,0 @@-/*- * Copyright (c) 2021, Ali Mohammad Pur <[email protected]>- * Copyright (c) 2023, Tim Schumacher <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <AK/ConstrainedStream.h>--namespace AK {--ConstrainedStream::ConstrainedStream(MaybeOwned<Stream> stream, u64 limit)- : m_stream(move(stream))- , m_limit(limit)-{-}--ErrorOr<void> ConstrainedStream::discard(size_t discarded_bytes)-{- if (discarded_bytes >= m_limit)- return Error::from_string_literal("Trying to discard more bytes than allowed");-- // Note: This will remove more bytes from the limit than intended if a failing discard yields partial results.- // However, stopping early is most likely better than running over the end of the stream.- m_limit -= discarded_bytes;- TRY(m_stream->discard(discarded_bytes));-- return {};-}--ErrorOr<size_t> ConstrainedStream::write_some(ReadonlyBytes)-{- return Error::from_errno(EBADF);-}--bool ConstrainedStream::is_eof() const-{- return m_limit == 0 || m_stream->is_eof();-}--bool ConstrainedStream::is_open() const-{- return m_stream->is_open();-}--void ConstrainedStream::close()-{-}--}diff --git a/AK/ConstrainedStream.h b/AK/ConstrainedStream.hdeleted file mode 100644index 5de7b8e8400..00000000000--- a/AK/ConstrainedStream.h+++ /dev/null@@ -1,38 +0,0 @@-/*- * Copyright (c) 2021, Ali Mohammad Pur <[email protected]>- * Copyright (c) 2023, Tim Schumacher <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/MaybeOwned.h>-#include <AK/Stream.h>--namespace AK {--class ConstrainedStream : public Stream {-public:- ConstrainedStream(MaybeOwned<Stream>, u64 limit);-- // NOTE: See the note on FixedMemoryStream::read_some() for why this needs explicit default visibility.- [[gnu::visibility("default")]] virtual ErrorOr<Bytes> read_some(Bytes bytes) override- {- auto result = TRY(m_stream->read_some(bytes.trim(m_limit)));- m_limit -= result.size();- return result;- }- virtual ErrorOr<void> discard(size_t discarded_bytes) override;- virtual ErrorOr<size_t> write_some(ReadonlyBytes) override;- virtual bool is_eof() const override;- virtual bool is_open() const override;- virtual void close() override;- u64 remaining() const { return m_limit; }--private:- MaybeOwned<Stream> m_stream;- u64 m_limit;-};--}diff --git a/AK/Forward.h b/AK/Forward.hindex 75cde6ac631..33cbdb09eb0 100644--- a/AK/Forward.h+++ b/AK/Forward.h@@ -34,7 +34,6 @@ class Bitmap;class ByteString;class ByteStringImpl;class CircularBuffer;-class ConstrainedStream;class CountingStream;class Duration;class Error;@@ -189,7 +188,6 @@ using AK::Bytes;using AK::ByteString;using AK::CircularBuffer;using AK::CircularQueue;-using AK::ConstrainedStream;using AK::CountingStream;using AK::DoublyLinkedList;using AK::Error;