LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all
This commit is contained in:
parent
5b318dd160
commit
9eeda5719e
Notes:
sideshowbarker
2024-07-17 00:23:42 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/9eeda5719e Pull-request: https://github.com/SerenityOS/serenity/pull/18906 Reviewed-by: https://github.com/gmta ✅
1 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue