1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09: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:
Lucas CHOLLET 2023-01-15 00:30:51 -05:00 committed by Sam Atkins
parent be28800e0d
commit 107e15c5bc
Notes: sideshowbarker 2024-07-17 04:10:16 +09:00
3 changed files with 6 additions and 10 deletions

View file

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