LibFileSystem+Everything: Remove resolve_executable_from_environment

This commit is contained in:
Ben Wiederhake 2023-05-29 22:20:05 +02:00 committed by Jelle Raaijmakers
parent 26efdf9d4f
commit f20d04726a
12 changed files with 12 additions and 23 deletions

View file

@ -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)

View file

@ -11,7 +11,6 @@
#include <LibCore/Account.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/Application.h>
#include <LibGUI/Desktop.h>
#include <LibGUI/MessageBox.h>
@ -38,7 +37,7 @@ ErrorOr<int> 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;

View file

@ -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;

View file

@ -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)

View file

@ -10,7 +10,6 @@
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibDesktop/Launcher.h>
#include <LibFileSystem/FileSystem.h>
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
@ -38,7 +37,7 @@ static ErrorOr<Vector<EngineDetails>> available_engines()
{
Vector<EngineDetails> 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;

View file

@ -359,12 +359,6 @@ ErrorOr<void> link_file(StringView destination_path, StringView source_path)
return TRY(Core::System::symlink(source_path, TRY(get_duplicate_file_name(destination_path))));
}
ErrorOr<String> 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);

View file

@ -73,7 +73,6 @@ bool can_delete_or_move(StringView path);
ErrorOr<String> read_link(StringView link_path);
ErrorOr<void> link_file(StringView destination_path, StringView source_path);
ErrorOr<String> resolve_executable_from_environment(StringView filename, int flags = 0);
bool looks_like_shared_library(StringView path);
}

View file

@ -375,7 +375,7 @@ ErrorOr<int> 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<int> Shell::builtin_kill(Main::Arguments arguments)
{
// Simply translate the arguments and pass them to `kill'
Vector<String> 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;

View file

@ -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(':');

View file

@ -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)

View file

@ -4,16 +4,16 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/MappedFile.h>
#include <LibCore/System.h>
#include <LibELF/Image.h>
#include <LibFileSystem/FileSystem.h>
#include <LibMain/Main.h>
static ErrorOr<bool> 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();

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <stdio.h>
#include <unistd.h>
@ -20,7 +20,7 @@ ErrorOr<int> 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;