mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:37:46 +00:00
AK: Move Stream
and SeekableStream
from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the `Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is defined by `SeekableStream`, since defining its own would require us to qualify it with `AK::SeekMode` everywhere.
This commit is contained in:
parent
5f2ea31816
commit
8464da1439
96 changed files with 620 additions and 586 deletions
|
@ -26,7 +26,7 @@ static ErrorOr<bool> format_file(StringView path, bool inplace)
|
|||
if (inplace && !read_from_stdin) {
|
||||
if (formatted_gml == contents)
|
||||
return true;
|
||||
TRY(file->seek(0, Core::Stream::SeekMode::SetPosition));
|
||||
TRY(file->seek(0, SeekMode::SetPosition));
|
||||
TRY(file->truncate(0));
|
||||
TRY(file->write(formatted_gml.bytes()));
|
||||
} else {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibMain/Main.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::Stream::File> input_stream, Core::Stream::Stream& output_stream)
|
||||
static ErrorOr<void> decompress_file(NonnullOwnPtr<Core::Stream::File> input_stream, AK::Stream& output_stream)
|
||||
{
|
||||
auto gzip_stream = Compress::GzipDecompressor { move(input_stream) };
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual void stream_into(Core::Stream::Stream&) override
|
||||
virtual void stream_into(AK::Stream&) override
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual void stream_into(Core::Stream::Stream&) override
|
||||
virtual void stream_into(AK::Stream&) override
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual void stream_into(Core::Stream::Stream&) override
|
||||
virtual void stream_into(AK::Stream&) override
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
if (seek_to.has_value())
|
||||
TRY(file->seek(seek_to.value(), Core::Stream::SeekMode::SetPosition));
|
||||
TRY(file->seek(seek_to.value(), SeekMode::SetPosition));
|
||||
|
||||
auto print_line = [](Bytes line) {
|
||||
VERIFY(line.size() <= LINE_LENGTH_BYTES);
|
||||
|
|
|
@ -84,7 +84,7 @@ static DeprecatedString s_history_path = DeprecatedString::formatted("{}/.js-his
|
|||
static int s_repl_line_level = 0;
|
||||
static bool s_fail_repl = false;
|
||||
|
||||
static ErrorOr<void> print(JS::Value value, Core::Stream::Stream& stream)
|
||||
static ErrorOr<void> print(JS::Value value, AK::Stream& stream)
|
||||
{
|
||||
JS::PrintContext print_context { .vm = *g_vm, .stream = stream, .strip_ansi = s_strip_ansi };
|
||||
return JS::print(value, print_context);
|
||||
|
|
|
@ -104,9 +104,9 @@ private:
|
|||
|
||||
/// Wraps a stream to silently ignore writes when the condition isn't true.
|
||||
template<typename ConditionT>
|
||||
class ConditionalOutputStream final : public Core::Stream::Stream {
|
||||
class ConditionalOutputStream final : public AK::Stream {
|
||||
public:
|
||||
ConditionalOutputStream(ConditionT&& condition, MaybeOwned<Core::Stream::Stream> stream)
|
||||
ConditionalOutputStream(ConditionT&& condition, MaybeOwned<AK::Stream> stream)
|
||||
: m_stream(move(stream))
|
||||
, m_condition(condition)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
MaybeOwned<Core::Stream::Stream> m_stream;
|
||||
MaybeOwned<AK::Stream> m_stream;
|
||||
ConditionT m_condition;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
static ErrorOr<void> tail_from_pos(Core::Stream::File& file, off_t startline)
|
||||
{
|
||||
TRY(file.seek(startline + 1, Core::Stream::SeekMode::SetPosition));
|
||||
TRY(file.seek(startline + 1, SeekMode::SetPosition));
|
||||
auto buffer = TRY(file.read_until_eof());
|
||||
out("{}", StringView { buffer });
|
||||
return {};
|
||||
|
@ -24,13 +24,13 @@ static ErrorOr<off_t> find_seek_pos(Core::Stream::File& file, int wanted_lines)
|
|||
{
|
||||
// Rather than reading the whole file, start at the end and work backwards,
|
||||
// stopping when we've found the number of lines we want.
|
||||
off_t pos = TRY(file.seek(0, Core::Stream::SeekMode::FromEndPosition));
|
||||
off_t pos = TRY(file.seek(0, SeekMode::FromEndPosition));
|
||||
|
||||
off_t end = pos;
|
||||
int lines = 0;
|
||||
|
||||
for (; pos >= 0; pos--) {
|
||||
TRY(file.seek(pos, Core::Stream::SeekMode::SetPosition));
|
||||
TRY(file.seek(pos, SeekMode::SetPosition));
|
||||
|
||||
if (file.is_eof())
|
||||
break;
|
||||
|
@ -102,7 +102,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(tail_from_pos(*f, pos));
|
||||
|
||||
if (follow) {
|
||||
TRY(f->seek(0, Core::Stream::SeekMode::FromEndPosition));
|
||||
TRY(f->seek(0, SeekMode::FromEndPosition));
|
||||
|
||||
Core::EventLoop event_loop;
|
||||
auto watcher = TRY(Core::FileWatcher::create());
|
||||
|
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto bytes = buffer_or_error.value().bytes();
|
||||
out("{}", StringView { bytes });
|
||||
|
||||
auto potential_error = f->seek(0, Core::Stream::SeekMode::FromEndPosition);
|
||||
auto potential_error = f->seek(0, SeekMode::FromEndPosition);
|
||||
if (potential_error.is_error()) {
|
||||
auto error = potential_error.error();
|
||||
warnln(error.string_literal());
|
||||
|
|
|
@ -64,7 +64,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!directory.is_empty())
|
||||
TRY(Core::System::chdir(directory));
|
||||
|
||||
NonnullOwnPtr<Core::Stream::Stream> input_stream = TRY(Core::Stream::File::open_file_or_standard_stream(archive_file, Core::Stream::OpenMode::Read));
|
||||
NonnullOwnPtr<AK::Stream> input_stream = TRY(Core::Stream::File::open_file_or_standard_stream(archive_file, Core::Stream::OpenMode::Read));
|
||||
|
||||
if (gzip)
|
||||
input_stream = make<Compress::GzipDecompressor>(move(input_stream));
|
||||
|
@ -206,7 +206,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 1;
|
||||
}
|
||||
|
||||
NonnullOwnPtr<Core::Stream::Stream> output_stream = TRY(Core::Stream::File::standard_output());
|
||||
NonnullOwnPtr<AK::Stream> output_stream = TRY(Core::Stream::File::standard_output());
|
||||
|
||||
if (!archive_file.is_empty())
|
||||
output_stream = TRY(Core::Stream::File::open(archive_file, Core::Stream::OpenMode::Write));
|
||||
|
|
|
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
json.remove(tty_name);
|
||||
}
|
||||
|
||||
TRY(file->seek(0, Core::Stream::SeekMode::SetPosition));
|
||||
TRY(file->seek(0, SeekMode::SetPosition));
|
||||
TRY(file->truncate(0));
|
||||
TRY(file->write(json.to_deprecated_string().bytes()));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
RefPtr<Line::Editor> g_line_editor;
|
||||
static OwnPtr<Core::Stream::Stream> g_stdout {};
|
||||
static OwnPtr<AK::Stream> g_stdout {};
|
||||
static OwnPtr<Wasm::Printer> g_printer {};
|
||||
static bool g_continue { false };
|
||||
static void (*old_signal)(int);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue