diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp index cc89a4a214a..f71e48c4d6a 100644 --- a/Meta/Lagom/Wasm/js_repl.cpp +++ b/Meta/Lagom/Wasm/js_repl.cpp @@ -65,7 +65,6 @@ void displayln() { user_display("\n", 1); } class UserDisplayStream final : public Core::Stream::Stream { virtual ErrorOr read(Bytes) override { return Error::from_string_view("Not readable"sv); }; - virtual bool is_writable() const override { return true; } virtual ErrorOr write(ReadonlyBytes bytes) override { user_display(bit_cast(bytes.data()), bytes.size()); diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cpp index cb6b4055926..0de1c01924a 100644 --- a/Tests/LibCore/TestLibCoreStream.cpp +++ b/Tests/LibCore/TestLibCoreStream.cpp @@ -29,8 +29,6 @@ TEST_CASE(file_open) // Testing out some basic file properties. auto file = maybe_file.release_value(); EXPECT(file->is_open()); - EXPECT(!file->is_readable()); - EXPECT(file->is_writable()); EXPECT(!file->is_eof()); auto maybe_size = file->size(); diff --git a/Userland/Libraries/LibCompress/Brotli.h b/Userland/Libraries/LibCompress/Brotli.h index cc321f18b5a..7fcf0550f7a 100644 --- a/Userland/Libraries/LibCompress/Brotli.h +++ b/Userland/Libraries/LibCompress/Brotli.h @@ -107,9 +107,7 @@ public: public: BrotliDecompressionStream(Stream&); - bool is_readable() const override { return m_input_stream.is_readable(); } ErrorOr read(Bytes output_buffer) override; - bool is_writable() const override { return m_input_stream.is_writable(); } ErrorOr write(ReadonlyBytes bytes) override { return m_input_stream.write(bytes); } bool is_eof() const override; bool is_open() const override { return m_input_stream.is_open(); } diff --git a/Userland/Libraries/LibCore/InputBitStream.h b/Userland/Libraries/LibCore/InputBitStream.h index e5340cb96f6..494963d2a86 100644 --- a/Userland/Libraries/LibCore/InputBitStream.h +++ b/Userland/Libraries/LibCore/InputBitStream.h @@ -30,7 +30,6 @@ public: } // ^Stream - virtual bool is_readable() const override { return m_stream.is_readable(); } virtual ErrorOr read(Bytes bytes) override { if (m_current_byte.has_value() && is_aligned_to_byte_boundary()) { @@ -40,7 +39,6 @@ public: align_to_byte_boundary(); return m_stream.read(bytes); } - virtual bool is_writable() const override { return m_stream.is_writable(); } virtual ErrorOr write(ReadonlyBytes bytes) override { return m_stream.write(bytes); } virtual bool write_or_error(ReadonlyBytes bytes) override { return m_stream.write_or_error(bytes); } virtual bool is_eof() const override { return m_stream.is_eof() && !m_current_byte.has_value(); } @@ -147,7 +145,6 @@ public: } // ^Stream - virtual bool is_readable() const override { return m_stream.is_readable(); } virtual ErrorOr read(Bytes bytes) override { if (m_current_byte.has_value() && is_aligned_to_byte_boundary()) { @@ -157,7 +154,6 @@ public: align_to_byte_boundary(); return m_stream.read(bytes); } - virtual bool is_writable() const override { return m_stream.is_writable(); } virtual ErrorOr write(ReadonlyBytes bytes) override { return m_stream.write(bytes); } virtual bool write_or_error(ReadonlyBytes bytes) override { return m_stream.write_or_error(bytes); } virtual bool is_eof() const override { return m_stream.is_eof() && !m_current_byte.has_value(); } diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index f598144c724..aab023c26f0 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -229,9 +229,6 @@ ErrorOr File::open_path(StringView filename, mode_t permissions) return {}; } -bool File::is_readable() const { return has_flag(m_mode, OpenMode::Read); } -bool File::is_writable() const { return has_flag(m_mode, OpenMode::Write); } - ErrorOr File::read(Bytes buffer) { if (!has_flag(m_mode, OpenMode::Read)) { diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h index 84785c11ca9..f57bcc04007 100644 --- a/Userland/Libraries/LibCore/Stream.h +++ b/Userland/Libraries/LibCore/Stream.h @@ -28,7 +28,6 @@ namespace Core::Stream { /// operations one can perform on every stream in LibCore. class Stream { public: - virtual bool is_readable() const { return false; } /// Reads into a buffer, with the maximum size being the size of the buffer. /// The amount of bytes read can be smaller than the size of the buffer. /// Returns either the bytes that were read, or an errno in the case of @@ -46,7 +45,6 @@ public: /// internal stack-based buffer. virtual ErrorOr discard(size_t discarded_bytes); - virtual bool is_writable() const { return false; } /// Tries to write the entire contents of the buffer. It is possible for /// less than the full buffer to be written. Returns either the amount of /// bytes written into the stream, or an errno in the case of failure. @@ -239,10 +237,8 @@ public: return *this; } - virtual bool is_readable() const override; virtual ErrorOr read(Bytes) override; virtual ErrorOr read_all(size_t block_size = 4096) override; - virtual bool is_writable() const override; virtual ErrorOr write(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; @@ -346,8 +342,6 @@ public: return *this; } - virtual bool is_readable() const override { return is_open(); } - virtual bool is_writable() const override { return is_open(); } virtual ErrorOr read(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } @@ -423,8 +417,6 @@ public: return m_helper.read(buffer, default_flags()); } - virtual bool is_readable() const override { return is_open(); } - virtual bool is_writable() const override { return is_open(); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.is_open(); } @@ -484,8 +476,6 @@ public: return *this; } - virtual bool is_readable() const override { return is_open(); } - virtual bool is_writable() const override { return is_open(); } virtual ErrorOr read(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } @@ -717,7 +707,7 @@ public: if (m_buffer.span().slice(0, m_buffered_size).contains_slow('\n')) return true; - if (!stream().is_readable()) + if (stream().is_eof()) return false; while (m_buffered_size < m_buffer.size()) { @@ -818,9 +808,7 @@ public: BufferedSeekable(BufferedSeekable&& other) = default; BufferedSeekable& operator=(BufferedSeekable&& other) = default; - virtual bool is_readable() const override { return m_helper.stream().is_readable(); } virtual ErrorOr read(Bytes buffer) override { return m_helper.read(move(buffer)); } - virtual bool is_writable() const override { return m_helper.stream().is_writable(); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.stream().write(buffer); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.stream().is_open(); } @@ -889,9 +877,7 @@ public: return *this; } - virtual bool is_readable() const override { return m_helper.stream().is_readable(); } virtual ErrorOr read(Bytes buffer) override { return m_helper.read(move(buffer)); } - virtual bool is_writable() const override { return m_helper.stream().is_writable(); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.stream().write(buffer); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.stream().is_open(); } @@ -977,9 +963,7 @@ public: return {}; } - virtual bool is_readable() const override { return m_socket.is_readable(); } virtual ErrorOr read(Bytes buffer) override { return m_socket.read(move(buffer)); } - virtual bool is_writable() const override { return m_socket.is_writable(); } virtual ErrorOr write(ReadonlyBytes buffer) override { return m_socket.write(buffer); } virtual bool is_eof() const override { return m_socket.is_eof(); } virtual bool is_open() const override { return m_socket.is_open(); } diff --git a/Userland/Libraries/LibTLS/TLSv12.h b/Userland/Libraries/LibTLS/TLSv12.h index c0bfb040baf..67339184bce 100644 --- a/Userland/Libraries/LibTLS/TLSv12.h +++ b/Userland/Libraries/LibTLS/TLSv12.h @@ -356,9 +356,6 @@ private: } public: - virtual bool is_readable() const override { return true; } - virtual bool is_writable() const override { return true; } - /// Reads into a buffer, with the maximum size being the size of the buffer. /// The amount of bytes read can be smaller than the size of the buffer. /// Returns either the bytes that were read, or an errno in the case of