[VD:LocalFileSystem] add an option statCorrector to correct stat data

Example for 32bit PHP on armv7l GNU/Linux see #2613

```php
array (
    'driver'        => 'LocalFileSystem',
    'path'          => '/path/to/files/',
    'statCorrector' => function (&$stat, $path, $statOwner,
$volumeDriveInstance) {
        if (isset($stat['size']) && $stat['mime'] !== 'directory') {
            if ($stat['size'] == '0') {
                // filesize problem for file larger than 4GB ( testing
                // in PHP Version 5.4.16)
                // https://stackoverflow.com/questions/6482211/php-filesize-over-4gb
                $stat['size'] = trim(shell_exec('stat -c %s
'.escapeshellarg($path)));
            }

            if ($stat['ts'] === false){
                // sometime filemtime will failed to return false
                $stat['ts'] = (int)trim(shell_exec('stat -c %Y
'.escapeshellarg($path)));
            }
        }
    }
)
```
This commit is contained in:
nao-pon
2018-08-18 14:18:36 +09:00
parent e1a988db6d
commit f05b84b0a6
+13 -1
View File
@@ -67,6 +67,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$this->options['detectDirIcon'] = ''; // file name that is detected as a folder icon e.g. '.diricon.png'
$this->options['keepTimestamp'] = array('copy', 'move'); // keep timestamp at inner filesystem allowed 'copy', 'move' and 'upload'
$this->options['substituteImg'] = true; // support substitute image with dim command
$this->options['statCorrector'] = null; // callable to correct stat data `function(&$stat, $path, $statOwner, $volumeDriveInstance){}`
}
/*********************************************************************/
@@ -117,7 +118,11 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
if (is_null($this->options['syncCheckFunc'])) {
$this->options['syncCheckFunc'] = array($this, 'localFileSystemInotify');
}
// check 'statCorrector'
if (empty($this->options['statCorrector']) || !is_callable($this->options['statCorrector'])) {
$this->options['statCorrector'] = null;
}
return true;
}
@@ -519,6 +524,10 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
}
}
if ($this->options['statCorrector']) {
call_user_func_array($this->options['statCorrector'], array(&$stat, $path, $this->statOwner, $this));
}
return $stat;
}
@@ -738,6 +747,9 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$stat['size'] = $dir ? 0 : $size;
}
if ($this->options['statCorrector']) {
call_user_func_array($this->options['statCorrector'], array(&$stat, $fpath, $this->statOwner, $this));
}
}
$cache[] = array($fpath, $stat);