瀏覽代碼

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

Ben Wiederhake 2 年之前
父節點
當前提交
9eeda5719e
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      Userland/Libraries/LibLine/Editor.cpp

+ 6 - 4
Userland/Libraries/LibLine/Editor.cpp

@@ -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);