mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +00:00
md: Port to Core::Stream
This commit is contained in:
parent
14ce07dd52
commit
9d34a1f4a7
1 changed files with 5 additions and 15 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue