summaryrefslogtreecommitdiff
path: root/Shell
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-21 13:29:36 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-21 16:19:18 +0200
commita19690170f879ee16df5dd910064b00b92f793ca (patch)
tree0be176a7f7cf6f40c06c3e07616499fc937ea04b /Shell
parentba3b561a40af8de42468e7987b8d84884294bf76 (diff)
downloadserenity-a19690170f879ee16df5dd910064b00b92f793ca.zip
LibCore: Make Core::File::open() return a Result<NNRP<File>, String>
It was impractical to return a RefPtr<File> since that left us no way to extract the error string. This is usually needed for the UI, so the old static open() got basically no use.
Diffstat (limited to 'Shell')
-rw-r--r--Shell/main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Shell/main.cpp b/Shell/main.cpp
index 612a013a4a..cba616c0ca 100644
--- a/Shell/main.cpp
+++ b/Shell/main.cpp
@@ -993,12 +993,13 @@ void load_history()
void save_history()
{
- auto history_file = Core::File::open(get_history_path(), Core::IODevice::WriteOnly, 0600);
- if (!history_file)
+ auto file_or_error = Core::File::open(get_history_path(), Core::IODevice::WriteOnly, 0600);
+ if (file_or_error.is_error())
return;
+ auto& file = *file_or_error.value();
for (const auto& line : editor.history()) {
- history_file->write(line);
- history_file->write("\n");
+ file.write(line);
+ file.write("\n");
}
}