1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

HackStudio: Port to Core::Stream::File :^)

This commit is contained in:
Karol Kosek 2022-12-18 19:36:23 +01:00 committed by Andreas Kling
parent 697d6ffb1d
commit 4784ad66b2
8 changed files with 72 additions and 66 deletions

View file

@ -17,6 +17,7 @@
#include <LibConfig/Client.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/Timer.h>
#include <LibCpp/SemanticSyntaxHighlighter.h>
#include <LibCpp/SyntaxHighlighter.h>
@ -231,14 +232,19 @@ void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hov
}
dbgln_if(EDITOR_DEBUG, "opening {}", it->value);
auto file = Core::File::construct(it->value);
if (!file->open(Core::OpenMode::ReadOnly)) {
dbgln("failed to open {}, {}", it->value, file->error_string());
auto file_or_error = Core::Stream::File::open(it->value, Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
dbgln("Failed to open {}, {}", it->value, file_or_error.error());
return;
}
auto man_document = Markdown::Document::parse(file->read_all());
auto buffer_or_error = file_or_error.release_value()->read_until_eof();
if (buffer_or_error.is_error()) {
dbgln("Couldn't read file: {}", buffer_or_error.error());
return;
}
auto man_document = Markdown::Document::parse(buffer_or_error.release_value());
if (!man_document) {
dbgln("failed to parse markdown");
return;