From f20d04726a9f4f475f44da3fa70c736e47b872e3 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 29 May 2023 22:20:05 +0200 Subject: [PATCH] LibFileSystem+Everything: Remove resolve_executable_from_environment --- Userland/Applications/Escalator/CMakeLists.txt | 2 +- Userland/Applications/Escalator/main.cpp | 3 +-- Userland/DevTools/UserspaceEmulator/main.cpp | 2 +- Userland/Games/Chess/CMakeLists.txt | 2 +- Userland/Games/Chess/main.cpp | 3 +-- Userland/Libraries/LibFileSystem/FileSystem.cpp | 6 ------ Userland/Libraries/LibFileSystem/FileSystem.h | 1 - Userland/Shell/Builtin.cpp | 4 ++-- Userland/Shell/Shell.cpp | 2 +- Userland/Utilities/CMakeLists.txt | 2 -- Userland/Utilities/pledge.cpp | 4 ++-- Userland/Utilities/which.cpp | 4 ++-- 12 files changed, 12 insertions(+), 23 deletions(-) diff --git a/Userland/Applications/Escalator/CMakeLists.txt b/Userland/Applications/Escalator/CMakeLists.txt index ef8f91636a..3078c620e4 100644 --- a/Userland/Applications/Escalator/CMakeLists.txt +++ b/Userland/Applications/Escalator/CMakeLists.txt @@ -16,4 +16,4 @@ set(GENERATED_SOURCES ) serenity_app(Escalator ICON app-escalator) -target_link_libraries(Escalator PRIVATE LibCore LibFileSystem LibDesktop LibGfx LibGUI LibMain) +target_link_libraries(Escalator PRIVATE LibCore LibDesktop LibGfx LibGUI LibMain) diff --git a/Userland/Applications/Escalator/main.cpp b/Userland/Applications/Escalator/main.cpp index c98b6b8681..6b238073a0 100644 --- a/Userland/Applications/Escalator/main.cpp +++ b/Userland/Applications/Escalator/main.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -38,7 +37,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); - auto executable_path = FileSystem::resolve_executable_from_environment(command[0], AT_EACCESS); + auto executable_path = Core::System::resolve_executable_from_environment(command[0], AT_EACCESS); if (executable_path.is_error()) { GUI::MessageBox::show_error(nullptr, DeprecatedString::formatted("Could not execute command {}: Command not found.", command[0])); return 127; diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp index 60efb38301..3f46eb6f1a 100644 --- a/Userland/DevTools/UserspaceEmulator/main.cpp +++ b/Userland/DevTools/UserspaceEmulator/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv, char** env) auto executable_path_or_error = arguments[0].contains('/') ? FileSystem::real_path(arguments[0]) - : FileSystem::resolve_executable_from_environment(arguments[0]); + : Core::System::resolve_executable_from_environment(arguments[0]); if (executable_path_or_error.is_error()) { reportln("Cannot find executable for '{}'."sv, arguments[0]); return 1; diff --git a/Userland/Games/Chess/CMakeLists.txt b/Userland/Games/Chess/CMakeLists.txt index 8eb2191c43..e1bc90fd2b 100644 --- a/Userland/Games/Chess/CMakeLists.txt +++ b/Userland/Games/Chess/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(Chess ICON app-chess) -target_link_libraries(Chess PRIVATE LibChess LibConfig LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibCore LibMain LibDesktop) +target_link_libraries(Chess PRIVATE LibChess LibConfig LibFileSystemAccessClient LibGfx LibGUI LibCore LibMain LibDesktop) diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index e591c1cfc6..7c1e385c3d 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -38,7 +37,7 @@ static ErrorOr> available_engines() { Vector available_engines; for (auto& engine : s_all_engines) { - auto path_or_error = FileSystem::resolve_executable_from_environment(engine.command); + auto path_or_error = Core::System::resolve_executable_from_environment(engine.command); if (path_or_error.is_error()) continue; diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index 8e4e6b8c78..8a12744562 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -359,12 +359,6 @@ ErrorOr link_file(StringView destination_path, StringView source_path) return TRY(Core::System::symlink(source_path, TRY(get_duplicate_file_name(destination_path)))); } -ErrorOr resolve_executable_from_environment(StringView filename, int flags) -{ - // FIXME: Callers should Call Core::System::resolve_executable_from_environment instead of FileSystem::resolve_executable_from_environment. - return Core::System::resolve_executable_from_environment(filename, flags); -} - bool looks_like_shared_library(StringView path) { return path.ends_with(".so"sv) || path.contains(".so."sv); diff --git a/Userland/Libraries/LibFileSystem/FileSystem.h b/Userland/Libraries/LibFileSystem/FileSystem.h index a16b6e4836..ec78c022d6 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.h +++ b/Userland/Libraries/LibFileSystem/FileSystem.h @@ -73,7 +73,6 @@ bool can_delete_or_move(StringView path); ErrorOr read_link(StringView link_path); ErrorOr link_file(StringView destination_path, StringView source_path); -ErrorOr resolve_executable_from_environment(StringView filename, int flags = 0); bool looks_like_shared_library(StringView path); } diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 2238de8b3c..3eb0066836 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -375,7 +375,7 @@ ErrorOr Shell::builtin_type(Main::Arguments arguments) } // check if its an executable in PATH - auto fullpath = FileSystem::resolve_executable_from_environment(command); + auto fullpath = Core::System::resolve_executable_from_environment(command); if (!fullpath.is_error()) { printf("%s is %s\n", command.characters(), escape_token(fullpath.release_value()).characters()); continue; @@ -1252,7 +1252,7 @@ ErrorOr Shell::builtin_kill(Main::Arguments arguments) { // Simply translate the arguments and pass them to `kill' Vector replaced_values; - auto kill_path_or_error = FileSystem::resolve_executable_from_environment("kill"sv); + auto kill_path_or_error = Core::System::resolve_executable_from_environment("kill"sv); if (kill_path_or_error.is_error()) { warnln("kill: `kill' not found in PATH"); return 126; diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 7c1a7d5510..02157fa0eb 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -1422,7 +1422,7 @@ void Shell::cache_path() cached_path.append({ RunnablePath::Kind::Alias, name }); } - // TODO: Can we make this rely on FileSystem::resolve_executable_from_environment()? + // TODO: Can we make this rely on Core::System::resolve_executable_from_environment()? DeprecatedString path = getenv("PATH"); if (!path.is_empty()) { auto directories = path.split(':'); diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 0c0e0aa95d..b9f1ebe0a0 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -121,7 +121,6 @@ target_link_libraries(notify PRIVATE LibGfx LibGUI) target_link_libraries(open PRIVATE LibDesktop LibFileSystem) target_link_libraries(passwd PRIVATE LibCrypt) target_link_libraries(paste PRIVATE LibGUI) -target_link_libraries(pledge PRIVATE LibFileSystem) target_link_libraries(pgrep PRIVATE LibRegex) target_link_libraries(pkill PRIVATE LibRegex) target_link_libraries(pls PRIVATE LibCrypt) @@ -149,7 +148,6 @@ target_link_libraries(usermod PRIVATE LibFileSystem) target_link_libraries(wallpaper PRIVATE LibGfx LibGUI) target_link_libraries(wasm PRIVATE LibFileSystem LibJS LibLine LibWasm) target_link_libraries(watch PRIVATE LibFileSystem) -target_link_libraries(which PRIVATE LibFileSystem) target_link_libraries(wsctl PRIVATE LibGUI LibIPC) target_link_libraries(xml PRIVATE LibFileSystem LibXML) target_link_libraries(xzcat PRIVATE LibCompress) diff --git a/Userland/Utilities/pledge.cpp b/Userland/Utilities/pledge.cpp index 33f46c955f..4d852f1928 100644 --- a/Userland/Utilities/pledge.cpp +++ b/Userland/Utilities/pledge.cpp @@ -4,16 +4,16 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include #include -#include #include static ErrorOr is_dynamically_linked_executable(StringView filename) { - auto executable = TRY(FileSystem::resolve_executable_from_environment(filename)); + auto executable = TRY(Core::System::resolve_executable_from_environment(filename)); auto file = TRY(Core::MappedFile::map(executable)); ELF::Image elf_image(file->bytes()); return elf_image.is_dynamic(); diff --git a/Userland/Utilities/which.cpp b/Userland/Utilities/which.cpp index 3407652cb2..85533dd1ca 100644 --- a/Userland/Utilities/which.cpp +++ b/Userland/Utilities/which.cpp @@ -4,9 +4,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include -#include #include #include @@ -20,7 +20,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(filename, "Name of executable", "executable"); args_parser.parse(arguments); - auto fullpath = FileSystem::resolve_executable_from_environment(filename); + auto fullpath = Core::System::resolve_executable_from_environment(filename); if (fullpath.is_error()) { warnln("no '{}' in path", filename); return 1;