1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

HexEditor: Use FileSystemAccessClient::try_* APIs

This commit is contained in:
Mustafa Quraish 2022-01-16 03:41:34 -05:00 committed by Andreas Kling
parent 0c98e553e8
commit aae96af812
5 changed files with 21 additions and 58 deletions

View file

@ -48,15 +48,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
if (arguments.argc > 1) {
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window->window_id(), arguments.strings[1]);
if (response.error != 0) {
if (response.error != -1)
GUI::MessageBox::show_error(window, String::formatted("Opening \"{}\" failed: {}", *response.chosen_file, strerror(response.error)));
// FIXME: Using `try_request_file_read_only_approved` doesn't work here since the file stored in the editor is only readable.
auto response = FileSystemAccessClient::Client::the().try_request_file(window, arguments.strings[1], Core::OpenMode::ReadWrite);
if (response.is_error())
return 1;
}
hex_editor_widget->open_file(*response.fd, *response.chosen_file);
hex_editor_widget->open_file(response.value());
}
return app->exec();