mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03:00
shot: Port to Core::Stream
This commit is contained in:
parent
84e817a9f2
commit
f22d7ddd98
Notes:
sideshowbarker
2024-07-17 04:15:29 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/f22d7ddd98 Pull-request: https://github.com/SerenityOS/serenity/pull/15244 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/demostanis
@ -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 }));
|
||||
|
Loading…
Reference in New Issue
Block a user