summaryrefslogtreecommitdiff
path: root/Userland/Utilities/markdown-check.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-09-14 16:18:44 +0100
committerLinus Groh <mail@linusgroh.de>2022-11-19 17:00:10 +0000
commit14ce07dd5234ba4f1e60e91a0c31ce32ce28fc4b (patch)
treea9064d76d659a8a52957ac89014f2b0caeef08c6 /Userland/Utilities/markdown-check.cpp
parentccebf8bf592efa6d8b3c6824b71c13665f103cc1 (diff)
downloadserenity-14ce07dd5234ba4f1e60e91a0c31ce32ce28fc4b.zip
markdown-check: Port to Core::Stream
Diffstat (limited to 'Userland/Utilities/markdown-check.cpp')
-rw-r--r--Userland/Utilities/markdown-check.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/Userland/Utilities/markdown-check.cpp b/Userland/Utilities/markdown-check.cpp
index 850c6b4c67..3218b90959 100644
--- a/Userland/Utilities/markdown-check.cpp
+++ b/Userland/Utilities/markdown-check.cpp
@@ -20,6 +20,7 @@
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
+#include <LibCore/Stream.h>
#include <LibMain/Main.h>
#include <LibMarkdown/Document.h>
#include <LibMarkdown/Visitor.h>
@@ -233,14 +234,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln("Reading and parsing Markdown files ...");
HashMap<String, MarkdownLinkage> files;
for (auto path : file_paths) {
- auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly);
+ auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
- warnln("Failed to read {}: {}", path, file_or_error.error());
+ warnln("Failed to open {}: {}", path, file_or_error.error());
// Since this should never happen anyway, fail early.
return file_or_error.release_error();
}
auto file = file_or_error.release_value();
- auto content_buffer = file->read_all();
+
+ auto content_buffer_or_error = file->read_all();
+ if (content_buffer_or_error.is_error()) {
+ warnln("Failed to read {}: {}", path, file_or_error.error());
+ // Since this should never happen anyway, fail early.
+ return file_or_error.release_error();
+ }
+ auto content_buffer = content_buffer_or_error.release_value();
+
auto content = StringView(content_buffer);
auto document = Markdown::Document::parse(content);
if (!document) {