mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibGUI: Base write_to_file(StringView path)
on the stream overload
`write_to_file(StringView path)` was based on the `Core::File` overload. The return type also changed from `bool` to `ErrorOr<void>` to ease error propagation.
This commit is contained in:
parent
be28800e0d
commit
107e15c5bc
3 changed files with 6 additions and 10 deletions
|
@ -79,7 +79,7 @@ void EditorWrapper::save()
|
|||
});
|
||||
file_picker_action->activate();
|
||||
}
|
||||
editor().write_to_file(filename());
|
||||
editor().write_to_file(filename()).release_value_but_fixme_should_propagate_errors();
|
||||
update_diff();
|
||||
editor().update();
|
||||
}
|
||||
|
|
|
@ -1458,15 +1458,11 @@ void TextEditor::timer_event(Core::TimerEvent&)
|
|||
update_cursor();
|
||||
}
|
||||
|
||||
bool TextEditor::write_to_file(DeprecatedString const& path)
|
||||
ErrorOr<void> TextEditor::write_to_file(StringView path)
|
||||
{
|
||||
auto file = Core::File::construct(path);
|
||||
if (!file->open(Core::OpenMode::WriteOnly | Core::OpenMode::Truncate)) {
|
||||
warnln("Error opening {}: {}", path, strerror(file->error()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return write_to_file(*file);
|
||||
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate));
|
||||
TRY(write_to_file(*file));
|
||||
return {};
|
||||
}
|
||||
|
||||
bool TextEditor::write_to_file(Core::File& file)
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
void insert_at_cursor_or_replace_selection(StringView);
|
||||
void replace_all_text_without_resetting_undo_stack(StringView text);
|
||||
bool write_to_file(DeprecatedString const& path);
|
||||
ErrorOr<void> write_to_file(StringView path);
|
||||
bool write_to_file(Core::File&);
|
||||
ErrorOr<void> write_to_file(Core::Stream::File&);
|
||||
bool has_selection() const { return m_selection.is_valid(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue