function scald_file_command_exists in Scald File Provider 7
Determines if a command exists on the current environment.
@codingStandardsIgnoreStart
Source: http://stackoverflow.com/questions/12424787/how-to-check-if-a-shell-comm...
Parameters
string $command: The command to check.
Return value
bool True if the command has been found ; otherwise, false.
1 call to scald_file_command_exists()
- _scald_file_pdf_thumbnail in ./
scald_file.module - Generate a thumbnail for a pdf file.
File
- ./
scald_file.module, line 488 - Scald File is a Scald Atom Provider for Files.
Code
function scald_file_command_exists($command) {
$whereIsCommand = PHP_OS == 'WINNT' ? 'where' : 'which';
// @codingStandardsIgnoreEnd
$process = proc_open("{$whereIsCommand} {$command}", array(
// STDIN.
0 => array(
"pipe",
"r",
),
// STDOUT.
1 => array(
"pipe",
"w",
),
// STDERR.
2 => array(
"pipe",
"w",
),
), $pipes);
if ($process !== FALSE) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $stdout != '';
}
return FALSE;
}