Merge pull request #12303 from owncloud/windows-unknown-command-command
Deduplicate findBinaryPath() and do not try "command -v" on windows
This commit is contained in:
commit
168fce0b18
|
@ -872,6 +872,23 @@ class OC_Helper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find a program
|
||||||
|
* Note: currently windows is not supported
|
||||||
|
*
|
||||||
|
* @param string $program
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public static function findBinaryPath($program) {
|
||||||
|
if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) {
|
||||||
|
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
||||||
|
if ($returnCode === 0 && count($output) > 0) {
|
||||||
|
return escapeshellcmd($output[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the disc space for the given path
|
* Calculate the disc space for the given path
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,28 +8,12 @@
|
||||||
*/
|
*/
|
||||||
namespace OC\Preview;
|
namespace OC\Preview;
|
||||||
|
|
||||||
function findBinaryPath($program) {
|
|
||||||
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
|
||||||
if ($returnCode === 0 && count($output) > 0) {
|
|
||||||
return escapeshellcmd($output[0]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// movie preview is currently not supported on Windows
|
// movie preview is currently not supported on Windows
|
||||||
if (!\OC_Util::runningOnWindows()) {
|
if (!\OC_Util::runningOnWindows()) {
|
||||||
$isExecEnabled = \OC_Helper::is_function_enabled('exec');
|
$avconvBinary = \OC_Helper::findBinaryPath('avconv');
|
||||||
$ffmpegBinary = null;
|
$ffmpegBinary = ($avconvBinary) ? null : \OC_Helper::findBinaryPath('ffmpeg');
|
||||||
$avconvBinary = null;
|
|
||||||
|
|
||||||
if ($isExecEnabled) {
|
if ($avconvBinary || $ffmpegBinary) {
|
||||||
$avconvBinary = findBinaryPath('avconv');
|
|
||||||
if (!$avconvBinary) {
|
|
||||||
$ffmpegBinary = findBinaryPath('ffmpeg');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($isExecEnabled && ( $avconvBinary || $ffmpegBinary )) {
|
|
||||||
|
|
||||||
class Movie extends Provider {
|
class Movie extends Provider {
|
||||||
public static $avconvBinary;
|
public static $avconvBinary;
|
||||||
|
|
|
@ -17,7 +17,7 @@ $config = \OC::$server->getConfig();
|
||||||
$appConfig = \OC::$server->getAppConfig();
|
$appConfig = \OC::$server->getAppConfig();
|
||||||
|
|
||||||
// Should we display sendmail as an option?
|
// Should we display sendmail as an option?
|
||||||
$template->assign('sendmail_is_available', (bool)findBinaryPath('sendmail'));
|
$template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
|
||||||
|
|
||||||
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
|
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
|
||||||
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
|
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
|
||||||
|
@ -115,19 +115,3 @@ $formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log'
|
||||||
$template->assign('forms', $formsAndMore);
|
$template->assign('forms', $formsAndMore);
|
||||||
|
|
||||||
$template->printPage();
|
$template->printPage();
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to find a program
|
|
||||||
*
|
|
||||||
* @param string $program
|
|
||||||
* @return null|string
|
|
||||||
*/
|
|
||||||
function findBinaryPath($program) {
|
|
||||||
if (OC_Helper::is_function_enabled('exec')) {
|
|
||||||
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
|
||||||
if ($returnCode === 0 && count($output) > 0) {
|
|
||||||
return escapeshellcmd($output[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue