diff options
author | Cameron Youell <cameronyouell@gmail.com> | 2023-03-22 02:35:30 +1100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-21 19:03:21 +0000 |
commit | 1d24f394c61d8e2af216c95303014d0554165f72 (patch) | |
tree | e577780754109c9b38a81cfc815d35f19c68eb9d /Userland/DevTools/HackStudio/HackStudioWidget.cpp | |
parent | edab0cbf41d80e805fe93ee0c4cc5021a1e599c1 (diff) | |
download | serenity-1d24f394c61d8e2af216c95303014d0554165f72.zip |
Everywhere: Use `LibFileSystem` where trivial
Diffstat (limited to 'Userland/DevTools/HackStudio/HackStudioWidget.cpp')
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index e631627a8d..ae2b2a2a5d 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -34,6 +34,7 @@ #include <LibCore/System.h> #include <LibDebug/DebugSession.h> #include <LibDesktop/Launcher.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> @@ -311,7 +312,7 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l if (full_filename.starts_with(project().root_path())) { filename = LexicalPath::relative_path(full_filename, project().root_path()); } - if (Core::DeprecatedFile::is_directory(filename) || !Core::DeprecatedFile::exists(filename)) + if (FileSystem::is_directory(filename) || !FileSystem::exists(filename)) return false; auto editor_wrapper_or_none = m_all_editor_wrappers.first_matching([&](auto& wrapper) { @@ -533,13 +534,13 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_file_action(Dep DeprecatedString filepath; if (!path_to_selected.is_empty()) { - VERIFY(Core::DeprecatedFile::exists(path_to_selected.first())); + VERIFY(FileSystem::exists(path_to_selected.first())); LexicalPath selected(path_to_selected.first()); DeprecatedString dir_path; - if (Core::DeprecatedFile::is_directory(selected.string())) + if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -573,7 +574,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_new_directory_actio DeprecatedString dir_path; - if (Core::DeprecatedFile::is_directory(selected.string())) + if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); @@ -681,7 +682,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action() } bool is_directory = S_ISDIR(st.st_mode); - if (auto result = Core::DeprecatedFile::remove(file, Core::DeprecatedFile::RecursionMode::Allowed); result.is_error()) { + if (auto result = FileSystem::remove(file, FileSystem::RecursionMode::Allowed); result.is_error()) { auto& error = result.error(); if (is_directory) { GUI::MessageBox::show(window(), @@ -1001,7 +1002,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_debug_action() { auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"sv)); return GUI::Action::create("&Debug", icon, [this](auto&) { - if (!Core::DeprecatedFile::exists(get_project_executable_path())) { + if (!FileSystem::exists(get_project_executable_path())) { GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -1249,7 +1250,7 @@ void HackStudioWidget::configure_project_tree_view() auto selections = m_project_tree_view->selection().indices(); auto it = selections.find_if([&](auto selected_file) { - return Core::DeprecatedFile::can_delete_or_move(m_project->model().full_path(selected_file)); + return FileSystem::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); @@ -1794,10 +1795,10 @@ ErrorOr<NonnullRefPtr<GUI::Action>> HackStudioWidget::create_open_project_config DeprecatedString formatted_error_string_holder; auto save_configuration_or_error = [&]() -> ErrorOr<void> { - if (Core::DeprecatedFile::exists(absolute_config_file_path)) + if (FileSystem::exists(absolute_config_file_path)) return {}; - if (Core::DeprecatedFile::exists(parent_directory) && !Core::DeprecatedFile::is_directory(parent_directory)) { + if (FileSystem::exists(parent_directory) && !FileSystem::is_directory(parent_directory)) { formatted_error_string_holder = DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory); return Error::from_string_view(formatted_error_string_holder); } |