LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all

This commit is contained in:
Ben Wiederhake 2023-05-18 15:32:38 +02:00 committed by Jelle Raaijmakers
parent 5b318dd160
commit 9eeda5719e
Notes: sideshowbarker 2024-07-17 00:23:42 +09:00

View file

@ -251,11 +251,13 @@ void Editor::add_to_history(DeprecatedString const& line)
bool Editor::load_history(DeprecatedString const& path)
{
auto history_file = Core::DeprecatedFile::construct(path);
if (!history_file->open(Core::OpenMode::ReadOnly))
auto history_file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
if (history_file_or_error.is_error())
return false;
auto data = history_file->read_all();
auto hist = StringView { data.data(), data.size() };
auto data_or_error = history_file_or_error.value()->read_until_eof();
if (data_or_error.is_error())
return false;
auto hist = StringView { data_or_error.value() };
for (auto& str : hist.split_view("\n\n"sv)) {
auto it = str.find("::"sv).value_or(0);
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);