1 | <?php |
||
15 | class WindowsSystem |
||
|
|||
16 | { |
||
17 | const PATH_SEPARATOR = ';'; |
||
18 | |||
19 | const FORBIDDEN_CHARS = '<>:"/\|?*'; |
||
20 | |||
21 | /** |
||
22 | * @var WindowsSystem |
||
23 | */ |
||
24 | private static $instance; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $exts; |
||
30 | |||
31 | /** |
||
32 | * an instance is bootstrapped in to prevent initialization overhead |
||
33 | * |
||
34 | * @return WindowsSystem |
||
35 | */ |
||
36 | private static function getInstance() |
||
42 | |||
43 | private function __construct() |
||
46 | |||
47 | /** |
||
48 | * @return array keys are uppercase extensions incl. dot |
||
49 | */ |
||
50 | private function getExecuteableExtesions() |
||
51 | { |
||
52 | // PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1 |
||
53 | $this->exts || $this->exts = array_flip(array_map( |
||
54 | 'strtoupper', |
||
55 | explode(self::PATH_SEPARATOR, getenv('PATHEXT')) |
||
56 | )); |
||
57 | |||
58 | return $this->exts; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * a name is executable based on it's extension |
||
63 | * |
||
64 | * @param string $name |
||
65 | * |
||
66 | * @return bool |
||
67 | */ |
||
68 | public static function isExecutableName($name) |
||
85 | |||
86 | /** |
||
87 | * a program (by it's basename) is available on system for execution |
||
88 | * |
||
89 | * @param string $program |
||
90 | * @return bool |
||
91 | */ |
||
92 | public static function isProgramInstalled($program) |
||
96 | |||
97 | /** |
||
98 | * Returns the absolute path to the program that should be located or an empty string if the programm |
||
99 | * could not be found. |
||
100 | * |
||
101 | * @param string $program |
||
102 | * @return string |
||
103 | */ |
||
104 | public static function locateProgram($program) |
||
137 | } |
||
138 |