diff options
author | Andreas Fischer <bantu@owncloud.com> | 2014-02-09 16:16:01 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2014-05-29 16:26:01 +0200 |
commit | df29eec72b2b094acca97636c6b91ab2eafc245d (patch) | |
tree | 2bb87ec6457907beaf71aadfd6bed4722c24cbff /lib | |
parent | 626e87aa542adaee123c7c4104411238b43b3333 (diff) | |
download | nextcloud-server-df29eec72b2b094acca97636c6b91ab2eafc245d.tar.gz nextcloud-server-df29eec72b2b094acca97636c6b91ab2eafc245d.zip |
Windows exec() implementation.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/largefilehelper.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/private/largefilehelper.php b/lib/private/largefilehelper.php index 751e60de539..5f5e14aca35 100644 --- a/lib/private/largefilehelper.php +++ b/lib/private/largefilehelper.php @@ -92,17 +92,26 @@ class LargeFileHelper { public function getFilesizeViaExec($filename) { if (\OC_Helper::is_function_enabled('exec')) { $os = strtolower(php_uname('s')); + $arg = escapeshellarg($filename); $result = ''; if (strpos($os, 'linux') !== false) { - $result = trim(exec('stat -c %s ' . escapeshellarg($filename))); + $result = $this->exec("stat -c %s $arg"); } else if (strpos($os, 'bsd') !== false) { - $result = trim(exec('stat -f %z ' . escapeshellarg($filename))); - } - - if (ctype_digit($result)) { - return 0 + $result; + $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; } return null; } + + protected function exec($cmd) { + $result = trim(exec($cmd)); + return ctype_digit($result) ? 0 + $result : null; + } } |