shot: Port to Core::Stream

This commit is contained in:
Sam Atkins 2022-09-14 17:06:14 +01:00 committed by Linus Groh
parent 84e817a9f2
commit f22d7ddd98
Notes: sideshowbarker 2024-07-17 04:15:29 +09:00

View File

@ -13,6 +13,7 @@
#include <LibCore/DateTime.h>
#include <LibCore/File.h>
#include <LibCore/Process.h>
#include <LibCore/Stream.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
#include <LibGUI/ConnectionToWindowServer.h>
@ -158,17 +159,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (edit_image)
output_path = Core::DateTime::now().to_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
auto file_or_error = Core::File::open(output_path, Core::OpenMode::ReadWrite);
auto file_or_error = Core::Stream::File::open(output_path, Core::Stream::OpenMode::ReadWrite);
if (file_or_error.is_error()) {
warnln("Could not open '{}' for writing: {}", output_path, file_or_error.error());
return 1;
}
auto& file = *file_or_error.value();
if (!file.write(encoded_bitmap.data(), encoded_bitmap.size())) {
warnln("Failed to write PNG");
return 1;
}
TRY(file.write(encoded_bitmap.bytes()));
if (edit_image)
TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path }));