Skip to content

Commit 9eeda57

Browse files
BenWiederhakegmta
authored andcommitted
LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all
1 parent 5b318dd commit 9eeda57

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Userland/Libraries/LibLine/Editor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,13 @@ void Editor::add_to_history(DeprecatedString const& line)
251251

252252
bool Editor::load_history(DeprecatedString const& path)
253253
{
254-
auto history_file = Core::DeprecatedFile::construct(path);
255-
if (!history_file->open(Core::OpenMode::ReadOnly))
254+
auto history_file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
255+
if (history_file_or_error.is_error())
256256
return false;
257-
auto data = history_file->read_all();
258-
auto hist = StringView { data.data(), data.size() };
257+
auto data_or_error = history_file_or_error.value()->read_until_eof();
258+
if (data_or_error.is_error())
259+
return false;
260+
auto hist = StringView { data_or_error.value() };
259261
for (auto& str : hist.split_view("\n\n"sv)) {
260262
auto it = str.find("::"sv).value_or(0);
261263
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);

0 commit comments

Comments
 (0)