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

@@ -6,7 +6,7 @@
#include "ProjectConfig.h"
#include <AK/NonnullOwnPtr.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
namespace HackStudio {
@@ -17,11 +17,10 @@ ProjectConfig::ProjectConfig(JsonObject config)
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString path)
{
auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
auto file_contents = file->read_all();
file->close();
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto file_contents = TRY(file->read_until_eof());
auto json = TRY(JsonValue::from_string(StringView { file_contents }));
auto json = TRY(JsonValue::from_string(file_contents));
if (!json.is_object())
return Error::from_string_literal("The topmost JSON element is not an object");