mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
committed by
Linus Groh
parent
39a3775f48
commit
5f99934dce
@@ -95,28 +95,6 @@ String DirIterator::next_full_path()
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
String find_executable_in_path(String filename)
|
||||
{
|
||||
if (filename.is_empty())
|
||||
return {};
|
||||
|
||||
if (filename.starts_with('/')) {
|
||||
if (access(filename.characters(), X_OK) == 0)
|
||||
return filename;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
for (auto directory : String { getenv("PATH") }.split(':')) {
|
||||
auto fullpath = String::formatted("{}/{}", directory, filename);
|
||||
|
||||
if (access(fullpath.characters(), X_OK) == 0)
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
int DirIterator::fd() const
|
||||
{
|
||||
if (!m_dir)
|
||||
|
||||
Reference in New Issue
Block a user