Skip to content

Commit

Permalink
Move function to LargeFileHelper
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
  • Loading branch information
LukasReschke committed Oct 25, 2016
1 parent cfc0d92 commit ea00bca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public function filemtime($path) {
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);
}
Expand Down
14 changes: 14 additions & 0 deletions lib/private/LargeFileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ public function getFileSizeNative($filename) {
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;
Expand Down

0 comments on commit ea00bca

Please sign in to comment.