1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:27:45 +00:00

Magnifier: Port to Core::Stream

This commit is contained in:
Lucas CHOLLET 2023-01-07 11:31:47 -05:00 committed by Sam Atkins
parent b8ec5c4470
commit a33a490d48

View file

@ -67,17 +67,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) { TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
AK::DeprecatedString filename = "file for saving"; AK::DeprecatedString filename = "file for saving";
auto do_save = [&]() -> ErrorOr<void> { auto do_save = [&]() -> ErrorOr<void> {
auto response = FileSystemAccessClient::Client::the().try_save_file_deprecated(window, "Capture", "png"); auto response = FileSystemAccessClient::Client::the().save_file(window, "Capture", "png");
if (response.is_error()) if (response.is_error())
return {}; return {};
auto file = response.release_value(); auto file = response.value().release_stream();
auto path = AK::LexicalPath(file->filename()); auto path = AK::LexicalPath(response.value().filename().to_deprecated_string());
filename = path.basename(); filename = path.basename();
auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension())); auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension()));
if (!file->write(encoded.data(), encoded.size())) { TRY(file->write(encoded));
return Error::from_errno(file->error());
}
return {}; return {};
}; };