diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index b61b902de2ec..9bed7d967692 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::runningOnLinux()) { + return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath)); + } else if (\OC_Util::runningOnBSD() || \OC_Util::runningOnMac()) { + 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..7dfd02117a0c 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::runningOnLinux()) { $result = $this->exec("stat -c %s $arg"); - } else if (strpos($os, 'bsd') !== false || strpos($os, 'darwin') !== false) { + } else if (\OC_Util::runningOnBSD() || \OC_Util::runningOnMac()) { $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..9c75a2d8b436 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::runningOnLinux()) { + if (\OC_Util::runningOnMac()) { + $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() + array($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 c7bc64969c80..f4c234270676 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -1252,13 +1252,31 @@ public static function obEnd() { } } + /** + * Checks whether the server is running on Linux + * + * @return bool true if running on Linux, false otherwise + */ + public static function runningOnLinux() { + return (strtolower(substr(PHP_OS, 0, 5)) === 'linux'); + } + /** * Checks whether the server is running on Mac OS X * * @return bool true if running on Mac OS X, false otherwise */ public static function runningOnMac() { - return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN'); + return (strtolower(substr(PHP_OS, 0, 6)) === 'darwin'); + } + + /** + * Checks whether the server is running on BSD + * + * @return bool true if running on BSD, false otherwise + */ + public static function runningOnBSD() { + return (strpos(strtolower(PHP_OS), 'bsd') !== false); } /**