mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 07:35:02 +03:00
md: Port to Core::Stream
This commit is contained in:
parent
14ce07dd52
commit
9d34a1f4a7
Notes:
sideshowbarker
2024-07-17 04:15:53 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/9d34a1f4a7 Pull-request: https://github.com/SerenityOS/serenity/pull/15244 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/demostanis
@ -6,7 +6,7 @@
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
TRY(Core::System::pledge("stdio rpath tty"));
|
||||
|
||||
char const* filename = nullptr;
|
||||
StringView filename;
|
||||
bool html = false;
|
||||
int view_width = 0;
|
||||
|
||||
@ -40,22 +40,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
view_width = 80;
|
||||
}
|
||||
}
|
||||
auto file = Core::File::construct();
|
||||
bool success;
|
||||
if (filename == nullptr) {
|
||||
success = file->open(STDIN_FILENO, Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
|
||||
} else {
|
||||
file->set_filename(filename);
|
||||
success = file->open(Core::OpenMode::ReadOnly);
|
||||
}
|
||||
if (!success) {
|
||||
warnln("Error: {}", file->error_string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(filename, Core::Stream::OpenMode::Read));
|
||||
|
||||
TRY(Core::System::pledge("stdio"));
|
||||
|
||||
auto buffer = file->read_all();
|
||||
auto buffer = TRY(file->read_all());
|
||||
dbgln("Read size {}", buffer.size());
|
||||
|
||||
auto input = String::copy(buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user