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

LibFileSystemAccessClient: Rename try_* functions to try_*_deprecated

These functions return the deprecated `Core::File` class, so let's mark
it as such to avoid possible confusion between future non try_*
functions which will use Core::Stream family classes and to possibly
grab someone's attention. :^)
This commit is contained in:
Karol Kosek 2022-12-17 00:58:13 +01:00 committed by Sam Atkins
parent e361025cfb
commit 247db3fdd0
22 changed files with 38 additions and 38 deletions

View file

@ -147,7 +147,7 @@ void GLContextWidget::drop_event(GUI::DropEvent& event)
if (url.scheme() != "file")
continue;
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), url.path(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), url.path(), Core::OpenMode::ReadOnly);
if (response.is_error())
return;
load_file(response.value());
@ -339,7 +339,7 @@ bool GLContextWidget::load_file(Core::File& file)
if (!bitmap_or_error.is_error())
texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
} else {
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), builder.string_view(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), builder.string_view(), Core::OpenMode::ReadOnly);
if (!response.is_error()) {
auto texture_file = response.value();
auto bitmap_or_error = Gfx::Bitmap::try_load_from_fd_and_close(texture_file->leak_fd(), texture_file->filename());
@ -398,7 +398,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(window);
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window);
if (response.is_error())
return;

View file

@ -121,7 +121,7 @@ HexEditorWidget::HexEditorWidget()
if (!request_close())
return;
auto response = FileSystemAccessClient::Client::the().try_open_file(window(), {}, Core::StandardPaths::home_directory(), Core::OpenMode::ReadWrite);
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window(), {}, Core::StandardPaths::home_directory(), Core::OpenMode::ReadWrite);
if (response.is_error())
return;
@ -586,7 +586,7 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event)
return;
// TODO: A drop event should be considered user consent for opening a file
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
if (response.is_error())
return;
open_file(response.value());

View file

@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (arguments.argc > 1) {
// 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);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window, arguments.strings[1], Core::OpenMode::ReadWrite);
if (response.is_error())
return 1;
hex_editor_widget->open_file(response.value());

View file

@ -211,7 +211,7 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
{
auto& file_menu = window.add_menu("&File");
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(&window);
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window);
if (!response.is_error())
open_file(*response.value());
}));

View file

@ -47,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
if (file_path) {
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, file_path);
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, file_path);
if (response.is_error())
return 1;
pdf_viewer_widget->open_file(*response.value());

View file

@ -710,7 +710,7 @@ void ImageEditor::save_project()
save_project_as();
return;
}
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), path(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), path(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
if (response.is_error())
return;
auto result = save_project_to_file(*response.value());

View file

@ -192,7 +192,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
});
m_open_image_action = GUI::CommonActions::make_open_action([&](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(&window);
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window);
if (response.is_error())
return;
open_image(response.value());
@ -415,7 +415,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
}));
m_edit_menu->add_action(GUI::Action::create(
"&Load Color Palette", g_icon_bag.load_color_palette, [&](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Load Color Palette");
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window, "Load Color Palette");
if (response.is_error())
return;
@ -1264,7 +1264,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
if (url.scheme() != "file")
continue;
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), url.path(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), url.path(), Core::OpenMode::ReadOnly);
if (response.is_error())
return;
open_image(response.value());

View file

@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->show();
if (image_file) {
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, image_file);
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, image_file);
if (response.is_error())
return 1;
main_widget->open_image(response.value());

View file

@ -30,7 +30,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
// Set up the menu bar.
auto& file_menu = window->add_menu("&File");
auto open_action = GUI::CommonActions::make_open_action([this](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(this->window());
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(this->window());
if (response.is_error())
return;
this->set_file(response.value()->filename());

View file

@ -127,14 +127,14 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
if (!request_close())
return;
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
if (response.is_error())
return;
load_file(*response.value());
});
m_import_action = GUI::Action::create("Import sheets...", [&](auto&) {
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
if (response.is_error())
return;
@ -147,7 +147,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
return;
}
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), current_filename(), Core::OpenMode::WriteOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), current_filename(), Core::OpenMode::WriteOnly);
if (response.is_error())
return;
save(*response.value());

View file

@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->show();
if (filename) {
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, filename));
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, filename));
spreadsheet_widget->load_file(file);
}

View file

@ -272,7 +272,7 @@ MainWidget::MainWidget()
return;
}
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
if (response.is_error())
return;
@ -303,7 +303,7 @@ MainWidget::MainWidget()
m_save_as_action->activate();
return;
}
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), m_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), m_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
if (response.is_error())
return;
@ -804,7 +804,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
return;
// TODO: A drop event should be considered user consent for opening a file
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
if (response.is_error())
return;
read_file(*response.value());

View file

@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (file_to_edit) {
FileArgument parsed_argument(file_to_edit);
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, parsed_argument.filename());
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, parsed_argument.filename());
if (response.is_error()) {
if (response.error().code() == ENOENT)

View file

@ -238,7 +238,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
return;
auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Select theme file", "/res/themes"sv);
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window, "Select theme file", "/res/themes"sv);
if (response.is_error())
return;
auto load_from_file_result = load_from_file(*response.value());
@ -250,7 +250,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
if (m_path.has_value()) {
auto result = FileSystemAccessClient::Client::the().try_request_file(&window, *m_path, Core::OpenMode::ReadWrite | Core::OpenMode::Truncate);
auto result = FileSystemAccessClient::Client::the().try_request_file_deprecated(&window, *m_path, Core::OpenMode::ReadWrite | Core::OpenMode::Truncate);
if (result.is_error())
return;
save_to_file(result.value());

View file

@ -170,7 +170,7 @@ void PreviewWidget::drop_event(GUI::DropEvent& event)
return;
}
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
if (response.is_error())
return;

View file

@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// Note: This is deferred to ensure that the window has already popped and thus proper window stealing can be performed.
app->event_loop().deferred_invoke(
[&window, &path, &main_widget]() {
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, path.value());
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, path.value());
if (response.is_error())
GUI::MessageBox::show_error(window, DeprecatedString::formatted("Opening \"{}\" failed: {}", path.value(), response.error()));
else {