ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Symfony\Component\Process\ExecutableFinder Class Reference

Generic executable finder. More...

+ Collaboration diagram for Symfony\Component\Process\ExecutableFinder:

Public Member Functions

 setSuffixes (array $suffixes)
 Replaces default suffixes of executable. More...
 
 addSuffix ($suffix)
 Adds new possible suffix to check for executable. More...
 
 find ($name, $default=null, array $extraDirs=array())
 Finds an executable by name. More...
 

Private Attributes

 $suffixes = array('.exe', '.bat', '.cmd', '.com')
 

Detailed Description

Generic executable finder.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com
Johannes M. Schmitt schmi.nosp@m.ttjo.nosp@m.h@gma.nosp@m.il.c.nosp@m.om

Definition at line 20 of file ExecutableFinder.php.

Member Function Documentation

◆ addSuffix()

Symfony\Component\Process\ExecutableFinder::addSuffix (   $suffix)

Adds new possible suffix to check for executable.

Parameters
string$suffix

Definition at line 39 of file ExecutableFinder.php.

40  {
41  $this->suffixes[] = $suffix;
42  }

◆ find()

Symfony\Component\Process\ExecutableFinder::find (   $name,
  $default = null,
array  $extraDirs = array() 
)

Finds an executable by name.

Parameters
string$nameThe executable name (without the extension)
string$defaultThe default to return if no executable is found
array$extraDirsAdditional dirs to check into
Returns
string The executable path or default value

Definition at line 53 of file ExecutableFinder.php.

References $file, $path, Symfony\Component\Process\ExecutableFinder\$suffixes, and array.

54  {
55  if (ini_get('open_basedir')) {
56  $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
57  $dirs = array();
58  foreach ($searchPath as $path) {
59  // Silencing against https://bugs.php.net/69240
60  if (@is_dir($path)) {
61  $dirs[] = $path;
62  } else {
63  if (basename($path) == $name && is_executable($path)) {
64  return $path;
65  }
66  }
67  }
68  } else {
69  $dirs = array_merge(
70  explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
71  $extraDirs
72  );
73  }
74 
75  $suffixes = array('');
76  if ('\\' === DIRECTORY_SEPARATOR) {
77  $pathExt = getenv('PATHEXT');
78  $suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
79  }
80  foreach ($suffixes as $suffix) {
81  foreach ($dirs as $dir) {
82  if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === DIRECTORY_SEPARATOR || is_executable($file))) {
83  return $file;
84  }
85  }
86  }
87 
88  return $default;
89  }
$path
Definition: aliased.php:25
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ setSuffixes()

Symfony\Component\Process\ExecutableFinder::setSuffixes ( array  $suffixes)

Replaces default suffixes of executable.

Parameters
array$suffixes

Definition at line 29 of file ExecutableFinder.php.

References Symfony\Component\Process\ExecutableFinder\$suffixes.

30  {
31  $this->suffixes = $suffixes;
32  }

Field Documentation

◆ $suffixes

Symfony\Component\Process\ExecutableFinder::$suffixes = array('.exe', '.bat', '.cmd', '.com')
private

The documentation for this class was generated from the following file: