mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
chore: deprecate \OC_Helper::canExecute
replace this legacy method with just the IBinaryFinder Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
a338772ddd
commit
85a6b0d0eb
2 changed files with 6 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
namespace OC\Files\Type;
|
||||
|
||||
use OCP\Files\IMimeTypeDetector;
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\ITempManager;
|
||||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -225,11 +226,13 @@ class Detection implements IMimeTypeDetector {
|
|||
}
|
||||
}
|
||||
|
||||
if (\OC_Helper::canExecute('file')) {
|
||||
$binaryFinder = \OCP\Server::get(IBinaryFinder::class);
|
||||
$program = $binaryFinder->findBinaryPath('file');
|
||||
if ($program !== false) {
|
||||
// it looks like we have a 'file' command,
|
||||
// lets see if it does have mime support
|
||||
$path = escapeshellarg($path);
|
||||
$fp = popen("test -f $path && file -b --mime-type $path", 'r');
|
||||
$fp = popen("test -f $path && $program -b --mime-type $path", 'r');
|
||||
if ($fp !== false) {
|
||||
$mimeType = fgets($fp);
|
||||
pclose($fp);
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ class OC_Helper {
|
|||
* @internal param string $program name
|
||||
* @internal param string $optional search path, defaults to $PATH
|
||||
* @return bool true if executable program found in path
|
||||
* @deprecated 32.0.0 use the \OCP\IBinaryFinder
|
||||
*/
|
||||
public static function canExecute($name, $path = false) {
|
||||
// path defaults to PATH from environment if not set
|
||||
|
|
|
|||
Loading…
Reference in a new issue