diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index b61b902de2ec..d1cc475225b5 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -180,7 +180,12 @@ public function filemtime($path) { return false; } if (PHP_INT_SIZE === 4) { - return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath)); + if (\OC_Util::runningOn('linux')) { + return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath)); + } else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) { + return (int) exec ('stat -f %m '. escapeshellarg ($fullPath)); + } + return false; } return filemtime($fullPath); } diff --git a/lib/private/LargeFileHelper.php b/lib/private/LargeFileHelper.php index 6f1cfacdb148..df142dd192fc 100644 --- a/lib/private/LargeFileHelper.php +++ b/lib/private/LargeFileHelper.php @@ -142,19 +142,12 @@ public function getFileSizeViaCurl($fileName) { */ public function getFileSizeViaExec($filename) { if (\OC_Helper::is_function_enabled('exec')) { - $os = strtolower(php_uname('s')); $arg = escapeshellarg($filename); $result = null; - if (strpos($os, 'linux') !== false) { + if (\OC_Util::runningOn('linux')) { $result = $this->exec("stat -c %s $arg"); - } else if (strpos($os, 'bsd') !== false || strpos($os, 'darwin') !== false) { + } else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) { $result = $this->exec("stat -f %z $arg"); - } else if (strpos($os, 'win') !== false) { - $result = $this->exec("for %F in ($arg) do @echo %~zF"); - if (is_null($result)) { - // PowerShell - $result = $this->exec("(Get-Item $arg).length"); - } } return $result; } diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 3abbb3d8cfe1..b54d2e3f0cc3 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -203,12 +203,18 @@ public function getSystemInfo($allowAllDatabases = false) { \OC\Setup::protectDataDirectory(); } - if (\OC_Util::runningOnMac()) { + if (!\OC_Util::runningOn('linux')) { + if (\OC_Util::runningOn('mac')) { + $os = 'Mac OS X'; + } else { + $os = PHP_OS; + } + $errors[] = [ 'error' => $this->l10n->t( - 'Mac OS X is not supported and %s will not work properly on this platform. ' . + '%s is not supported and %s will not work properly on this platform. ' . 'Use it at your own risk! ', - $this->defaults->getName() + [$os, $this->defaults->getName()] ), 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.') ]; diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index c44f828a3f8d..303066055930 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -1250,12 +1250,19 @@ public static function obEnd() { } /** - * Checks whether the server is running on Mac OS X + * Checks whether the server is running on the given OS type * - * @return bool true if running on Mac OS X, false otherwise + * @param string $osType linux|mac|bsd etc + * @return bool true if running on that OS type, false otherwise */ - public static function runningOnMac() { - return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN'); + public static function runningOn($osType) { + $osType = strtolower($osType) === 'mac' ? 'darwin' : strtolower($osType); + + if ($osType === 'bsd') { + return (strpos(strtolower(PHP_OS), $osType) !== false); + } else { + return (strtolower(substr(PHP_OS, 0, strlen($osType))) === $osType); + } } /**