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 | |
parent | edab0cbf41d80e805fe93ee0c4cc5021a1e599c1 (diff) | |
download | serenity-1d24f394c61d8e2af216c95303014d0554165f72.zip |
Everywhere: Use `LibFileSystem` where trivial
Diffstat (limited to 'Userland/DevTools/HackStudio')
-rw-r--r-- | Userland/DevTools/HackStudio/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp | 6 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 4 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 19 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Project.cpp | 4 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/ProjectBuilder.cpp | 10 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/ProjectTemplate.cpp | 7 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/main.cpp | 3 |
8 files changed, 29 insertions, 26 deletions
diff --git a/Userland/DevTools/HackStudio/CMakeLists.txt b/Userland/DevTools/HackStudio/CMakeLists.txt index ecd3c084a2..92373ace9e 100644 --- a/Userland/DevTools/HackStudio/CMakeLists.txt +++ b/Userland/DevTools/HackStudio/CMakeLists.txt @@ -54,5 +54,5 @@ set(GENERATED_SOURCES ) serenity_app(HackStudio ICON app-hack-studio) -target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibIPC LibJS LibMain LibThreading) +target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading) add_dependencies(HackStudio CppLanguageServer) diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 597b50860c..21fae01e08 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -12,8 +12,8 @@ #include <AK/DeprecatedString.h> #include <AK/LexicalPath.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/Directory.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> #include <LibGUI/FilePicker.h> @@ -150,7 +150,7 @@ Optional<DeprecatedString> NewProjectDialog::get_available_project_name() ? chosen_name : DeprecatedString::formatted("{}-{}", chosen_name, i); - if (!Core::DeprecatedFile::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) + if (!FileSystem::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) return candidate; } @@ -188,7 +188,7 @@ void NewProjectDialog::do_create_project() } auto create_in = m_create_in_input->text(); - if (!Core::DeprecatedFile::exists(create_in) || !Core::DeprecatedFile::is_directory(create_in)) { + if (!FileSystem::exists(create_in) || !FileSystem::is_directory(create_in)) { auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (result != GUI::MessageBox::ExecResult::Yes) return; diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 0fe712fd44..ad0f9f81ac 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -16,11 +16,11 @@ #include <LibCMake/CMakeCache/SyntaxHighlighter.h> #include <LibCMake/SyntaxHighlighter.h> #include <LibConfig/Client.h> -#include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> #include <LibCore/Timer.h> #include <LibCpp/SemanticSyntaxHighlighter.h> #include <LibCpp/SyntaxHighlighter.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> #include <LibGUI/GML/AutocompleteProvider.h> @@ -424,7 +424,7 @@ static HashMap<DeprecatedString, DeprecatedString>& include_paths() Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots); while (it.has_next()) { auto path = it.next_full_path(); - if (!Core::DeprecatedFile::is_directory(path)) { + if (!FileSystem::is_directory(path)) { auto key = path.substring(base.length() + 1, path.length() - base.length() - 1); dbgln_if(EDITOR_DEBUG, "Adding header \"{}\" in path \"{}\"", key, path); paths.set(key, path); 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); } diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index f15a33fc6c..1358958cc2 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -6,7 +6,7 @@ #include "Project.h" #include "HackStudio.h" -#include <LibCore/DeprecatedFile.h> +#include <LibFileSystem/FileSystem.h> namespace HackStudio { @@ -18,7 +18,7 @@ Project::Project(DeprecatedString const& root_path) OwnPtr<Project> Project::open_with_root_path(DeprecatedString const& root_path) { - if (!Core::DeprecatedFile::is_directory(root_path)) + if (!FileSystem::is_directory(root_path)) return {}; return adopt_own(*new Project(root_path)); } diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index b18ee7a99e..91f3141721 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -7,7 +7,7 @@ #include "ProjectBuilder.h" #include <AK/LexicalPath.h> #include <LibCore/Command.h> -#include <LibCore/DeprecatedFile.h> +#include <LibFileSystem/FileSystem.h> #include <LibRegex/Regex.h> #include <fcntl.h> #include <sys/stat.h> @@ -124,15 +124,15 @@ ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_p ErrorOr<void> ProjectBuilder::initialize_build_directory() { - if (!Core::DeprecatedFile::exists(build_directory())) { + if (!FileSystem::exists(build_directory())) { if (mkdir(LexicalPath::join(build_directory()).string().characters(), 0700)) { return Error::from_errno(errno); } } auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt"sv).string(); - if (Core::DeprecatedFile::exists(cmake_file_path)) - MUST(Core::DeprecatedFile::remove(cmake_file_path, Core::DeprecatedFile::RecursionMode::Disallowed)); + if (FileSystem::exists(cmake_file_path)) + MUST(FileSystem::remove(cmake_file_path, FileSystem::RecursionMode::Disallowed)); auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write)); TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes())); @@ -150,7 +150,7 @@ Optional<DeprecatedString> ProjectBuilder::find_cmake_file_for(StringView file_p auto directory = LexicalPath::dirname(file_path); while (!directory.is_empty()) { auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt"sv); - if (Core::DeprecatedFile::exists(cmake_path.string())) + if (FileSystem::exists(cmake_path.string())) return cmake_path.string(); directory = LexicalPath::dirname(directory); } diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 3f4983ab2e..9f9b0892bd 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -11,6 +11,7 @@ #include <LibCore/ConfigFile.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/DirIterator.h> +#include <LibFileSystem/FileSystem.h> #include <fcntl.h> #include <spawn.h> #include <sys/stat.h> @@ -52,7 +53,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); - if (Core::DeprecatedFile::exists(bitmap_path_32)) { + if (FileSystem::exists(bitmap_path_32)) { auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32); if (!bitmap_or_error.is_error()) icon = GUI::Icon(bitmap_or_error.release_value()); @@ -64,14 +65,14 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString con Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path) { // Check if a file or directory already exists at the project path - if (Core::DeprecatedFile::exists(path)) + if (FileSystem::exists(path)) return DeprecatedString("File or directory already exists at specified location."); dbgln("Creating project at path '{}' with name '{}'", path, name); // Verify that the template content directory exists. If it does, copy it's contents. // Otherwise, create an empty directory at the project path. - if (Core::DeprecatedFile::is_directory(content_path())) { + if (FileSystem::is_directory(content_path())) { auto result = Core::DeprecatedFile::copy_file_or_directory(path, content_path()); dbgln("Copying {} -> {}", content_path(), path); if (result.is_error()) diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index aaed97dade..abf1777a21 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -13,6 +13,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DeprecatedFile.h> #include <LibCore/System.h> +#include <LibFileSystem/FileSystem.h> #include <LibGUI/Application.h> #include <LibGUI/Menubar.h> #include <LibGUI/MessageBox.h> @@ -140,7 +141,7 @@ static Optional<DeprecatedString> last_opened_project_path() if (projects.size() == 0) return {}; - if (!Core::DeprecatedFile::exists(projects[0])) + if (!FileSystem::exists(projects[0])) return {}; return { projects[0] }; |