diff --git a/Blacklight/utility/Utility.php b/Blacklight/utility/Utility.php index 2b6808112..8cfd647dc 100755 --- a/Blacklight/utility/Utility.php +++ b/Blacklight/utility/Utility.php @@ -48,11 +48,7 @@ class Utility public static function clearScreen(): void { if (self::isCLI()) { - if (self::isWin()) { - passthru('cls'); - } else { - passthru('clear'); - } + passthru('clear'); } } @@ -189,29 +185,16 @@ class Utility /** * Detect if the command is accessible on the system. * + * * @param $cmd * - * @return bool|null Returns true if found, false if not found, and null if which is not detected. + * @return bool */ - public static function hasCommand($cmd): ?bool + public static function hasCommand($cmd): bool { - if ('HAS_WHICH') { - $returnVal = shell_exec("which $cmd"); + $returnVal = shell_exec("which $cmd"); - return empty($returnVal) ? false : true; - } - - return null; - } - - /** - * Check for availability of which command. - */ - public static function hasWhich(): bool - { - exec('which which', $output, $error); - - return ! $error; + return empty($returnVal) ? false : true; } /** @@ -264,14 +247,6 @@ class Utility return true; } - /** - * @return bool - */ - public static function isWin(): bool - { - return stripos(PHP_OS, 'win') === 0; - } - /** * @param array $elements * @param string $prefix @@ -689,7 +664,7 @@ class Utility public static function fileInfo($path) { $magicPath = Settings::settingValue('apps.indexer.magic_file_path'); - if (self::hasCommand('file') && (! self::isWin() || $magicPath !== null)) { + if ($magicPath !== null && self::hasCommand('file')) { $magicSwitch = $magicPath === null ? '' : " -m $magicPath"; $output = self::runCmd('file'.$magicSwitch.' -b "'.$path.'"'); @@ -760,16 +735,6 @@ class Utility return ''; } - /** - * Check if O/S is windows. - * - * @return bool - */ - public static function isWindows(): bool - { - return self::isWin(); - } - /** * Convert obj to array. * diff --git a/Changelog b/Changelog index 590eed140..dac67a347 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-07-23 DariusIII + * Chg: Remove isWin/isWindows functions and remove HAS_WHICH definition and usage * Chg: Update ZipFile class * Chg: Update imdbphp/imdbphp to latest commit 2018-07-20 DariusIII diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 38335b9ff..10beae27f 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -6,13 +6,8 @@ require_once 'constants.php'; require_once __DIR__.DIRECTORY_SEPARATOR.'yenc.php'; use Dotenv\Dotenv; -use Blacklight\utility\Utility; $dotenv = new Dotenv(dirname(__DIR__, 1)); $dotenv->load(); -if (! defined('HAS_WHICH')) { - define('HAS_WHICH', Utility::hasWhich() ? true : false); -} - $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); diff --git a/cli/data/predb_import_daily_batch.php b/cli/data/predb_import_daily_batch.php index dec58656c..1c52db9d5 100755 --- a/cli/data/predb_import_daily_batch.php +++ b/cli/data/predb_import_daily_batch.php @@ -28,13 +28,11 @@ use Blacklight\ColorCLI; use Blacklight\db\PreDb; use Blacklight\utility\Utility; -if (! Utility::isWin()) { - $canExeRead = Utility::canExecuteRead(NN_RES); +$canExeRead = Utility::canExecuteRead(NN_RES); if (is_string($canExeRead)) { exit($canExeRead); } unset($canExeRead); -} if (! is_writable(NN_RES)) { exit('The ('.NN_RES.') folder must be writable.'.PHP_EOL);