File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Userland/Libraries/LibCore Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -830,4 +830,33 @@ bool WrapInAKInputStream::discard_or_error(size_t count)
830
830
return true ;
831
831
}
832
832
833
+ WrapInAKOutputStream::WrapInAKOutputStream (Core::Stream::Stream& stream)
834
+ : m_stream(stream)
835
+ {
836
+ }
837
+
838
+ size_t WrapInAKOutputStream::write (ReadonlyBytes bytes)
839
+ {
840
+ if (has_any_error ())
841
+ return 0 ;
842
+
843
+ auto length_or_error = m_stream.write (bytes);
844
+ if (length_or_error.is_error ()) {
845
+ set_fatal_error ();
846
+ return 0 ;
847
+ }
848
+
849
+ return length_or_error.value ();
850
+ }
851
+
852
+ bool WrapInAKOutputStream::write_or_error (ReadonlyBytes bytes)
853
+ {
854
+ if (write (bytes) < bytes.size ()) {
855
+ set_fatal_error ();
856
+ return false ;
857
+ }
858
+
859
+ return true ;
860
+ }
861
+
833
862
}
Original file line number Diff line number Diff line change @@ -1041,4 +1041,15 @@ class WrapInAKInputStream final : public InputStream {
1041
1041
Core::Stream::Stream& m_stream;
1042
1042
};
1043
1043
1044
+ // Note: This is only a temporary hack, to break up the task of moving away from AK::Stream into smaller parts.
1045
+ class WrapInAKOutputStream final : public OutputStream {
1046
+ public:
1047
+ WrapInAKOutputStream (Core::Stream::Stream& stream);
1048
+ virtual size_t write (ReadonlyBytes) override ;
1049
+ virtual bool write_or_error (ReadonlyBytes) override ;
1050
+
1051
+ private:
1052
+ Core::Stream::Stream& m_stream;
1053
+ };
1054
+
1044
1055
}
You can’t perform that action at this time.
0 commit comments