mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all
This commit is contained in:
parent
5b318dd160
commit
9eeda5719e
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)
|
bool Editor::load_history(DeprecatedString const& path)
|
||||||
{
|
{
|
||||||
auto history_file = Core::DeprecatedFile::construct(path);
|
auto history_file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||||
if (!history_file->open(Core::OpenMode::ReadOnly))
|
if (history_file_or_error.is_error())
|
||||||
return false;
|
return false;
|
||||||
auto data = history_file->read_all();
|
auto data_or_error = history_file_or_error.value()->read_until_eof();
|
||||||
auto hist = StringView { data.data(), data.size() };
|
if (data_or_error.is_error())
|
||||||
|
return false;
|
||||||
|
auto hist = StringView { data_or_error.value() };
|
||||||
for (auto& str : hist.split_view("\n\n"sv)) {
|
for (auto& str : hist.split_view("\n\n"sv)) {
|
||||||
auto it = str.find("::"sv).value_or(0);
|
auto it = str.find("::"sv).value_or(0);
|
||||||
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);
|
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue