diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index d9f571bebf..4048d48955 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -555,7 +555,7 @@ bool DirectoryView::can_modify_current_selection() // FIXME: remove once Clang formats this properly. // clang-format off return selections.first_matching([&](auto& index) { - return !Core::System::access(node(index.parent()).full_path(), W_OK).is_error(); + return Core::File::can_delete_or_move(node(index).full_path()); }).has_value(); // clang-format on } diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 1ca1c635bf..4ed24cdb7d 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -31,7 +31,6 @@ #include #include #include -#include static constexpr auto APP_NAME = "Space Analyzer"sv; @@ -137,15 +136,6 @@ static ErrorOr analyze(RefPtr tree, SpaceAnalyzer::TreeMapWidget& tr return {}; } -static bool is_removable(DeprecatedString const& absolute_path) -{ - VERIFY(!absolute_path.is_empty()); - int access_result = access(LexicalPath::dirname(absolute_path).characters(), W_OK); - if (access_result != 0 && errno != EACCES) - perror("access"); - return access_result == 0; -} - static DeprecatedString get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& treemapwidget, bool include_last_node = true) { StringBuilder path_builder; @@ -288,7 +278,7 @@ ErrorOr serenity_main(Main::Arguments arguments) DeprecatedString selected_node_path = get_absolute_path_to_selected_node(treemapwidget); if (selected_node_path.is_empty()) return; - delete_action->set_enabled(is_removable(selected_node_path)); + delete_action->set_enabled(Core::File::can_delete_or_move(selected_node_path)); if (Core::File::is_directory(selected_node_path)) { open_folder_action->set_visible(true); open_containing_folder_action->set_visible(false); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 1fe5258218..2cad952518 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1245,7 +1245,7 @@ void HackStudioWidget::configure_project_tree_view() auto selections = m_project_tree_view->selection().indices(); auto it = selections.find_if([&](auto selected_file) { - return access(m_project->model().full_path(selected_file.parent()).characters(), W_OK) == 0; + return Core::File::can_delete_or_move(m_project->model().full_path(selected_file)); }); bool has_permissions = it != selections.end(); m_tree_view_rename_action->set_enabled(has_permissions);