Move function to LargeFileHelper

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Lukas Reschke 2016-10-25 11:42:16 +02:00
parent cfc0d9249b
commit 459477e2c3
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
2 changed files with 16 additions and 1 deletions

View File

@ -179,7 +179,8 @@ class Local extends \OC\Files\Storage\Common {
return false;
}
if (PHP_INT_SIZE === 4) {
return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath));
$helper = new \OC\LargeFileHelper();
return $helper->getFileMtime($fullPath);
}
return filemtime($fullPath);
}

View File

@ -187,6 +187,20 @@ class LargeFileHelper {
return $result;
}
/**
* Returns the current mtime for $fullPath
*
* @param string $fullPath
* @return int
*/
public function getFileMtime($fullPath) {
if (\OC_Helper::is_function_enabled('exec')) {
return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));
}
return filemtime($fullPath);
}
protected function exec($cmd) {
$result = trim(exec($cmd));
return ctype_digit($result) ? 0 + $result : null;