mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:37:45 +00:00
Userland: Consolidate most PATH resolving into a single implementation
We previously had at least three different implementations for resolving executables in the PATH, all of which had slightly different characteristics. Merge those into a single implementation to keep the behaviour consistent, and maybe to make that implementation more configurable in the future.
This commit is contained in:
parent
39a3775f48
commit
5f99934dce
13 changed files with 74 additions and 95 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibELF/Image.h>
|
||||
|
@ -12,12 +13,12 @@
|
|||
|
||||
static ErrorOr<bool> is_dynamically_linked_executable(StringView filename)
|
||||
{
|
||||
String exec_filename = filename;
|
||||
if (!filename.contains('/')) {
|
||||
exec_filename = TRY(Core::System::find_file_in_path(filename));
|
||||
}
|
||||
auto maybe_executable = Core::File::resolve_executable_from_environment(filename);
|
||||
|
||||
auto file = TRY(Core::MappedFile::map(exec_filename));
|
||||
if (!maybe_executable.has_value())
|
||||
return ENOENT;
|
||||
|
||||
auto file = TRY(Core::MappedFile::map(maybe_executable.release_value()));
|
||||
ELF::Image elf_image(file->bytes());
|
||||
return elf_image.is_dynamic();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue