[VD:abstract,LocalFileSystem] use symlink to getItemsInHand()

This commit is contained in:
nao-pon
2020-04-10 17:35:21 +09:00
parent 3e7a338b0e
commit 37519c120f
2 changed files with 24 additions and 5 deletions
+5 -5
View File
@@ -4364,7 +4364,7 @@ abstract class elFinderVolumeDriver
!empty($file['ts']) && touch($target, $file['ts']);
} else {
$path = $this->decode($hash);
if (!$canLink || !($canLink = link($path, $target)) || !($canLink = is_readable($path))) {
if (!$canLink || !($canLink = $this->localFileSystemSymlink($path, $target))) {
if (file_exists($target)) {
unlink($target);
}
@@ -6668,24 +6668,24 @@ abstract class elFinderVolumeDriver
$this->procExec(ELFINDER_TAR_PATH . ' --version', $o, $ctar);
if ($ctar == 0) {
$arcs['create']['application/x-tar'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-cf', 'ext' => 'tar');
$arcs['create']['application/x-tar'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-chf', 'ext' => 'tar');
$arcs['extract']['application/x-tar'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-xf', 'ext' => 'tar', 'toSpec' => '-C ', 'getsize' => array('argc' => '-xvf', 'toSpec' => '--to-stdout|wc -c', 'regex' => '/^.+(?:\r\n|\n|\r)[^\r\n0-9]*([0-9]+)[^\r\n]*$/s', 'replace' => '$1'));
unset($o);
$this->procExec(ELFINDER_GZIP_PATH . ' --version', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-gzip'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-czf', 'ext' => 'tgz');
$arcs['create']['application/x-gzip'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-czhf', 'ext' => 'tgz');
$arcs['extract']['application/x-gzip'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-xzf', 'ext' => 'tgz', 'toSpec' => '-C ', 'getsize' => array('argc' => '-xvf', 'toSpec' => '--to-stdout|wc -c', 'regex' => '/^.+(?:\r\n|\n|\r)[^\r\n0-9]*([0-9]+)[^\r\n]*$/s', 'replace' => '$1'));
}
unset($o);
$this->procExec(ELFINDER_BZIP2_PATH . ' --version', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-bzip2'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-cjf', 'ext' => 'tbz');
$arcs['create']['application/x-bzip2'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-cjhf', 'ext' => 'tbz');
$arcs['extract']['application/x-bzip2'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-xjf', 'ext' => 'tbz', 'toSpec' => '-C ', 'getsize' => array('argc' => '-xvf', 'toSpec' => '--to-stdout|wc -c', 'regex' => '/^.+(?:\r\n|\n|\r)[^\r\n0-9]*([0-9]+)[^\r\n]*$/s', 'replace' => '$1'));
}
unset($o);
$this->procExec(ELFINDER_XZ_PATH . ' --version', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-xz'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-cJf', 'ext' => 'xz');
$arcs['create']['application/x-xz'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-cJhf', 'ext' => 'xz');
$arcs['extract']['application/x-xz'] = array('cmd' => ELFINDER_TAR_PATH, 'argc' => '-xJf', 'ext' => 'xz', 'toSpec' => '-C ', 'getsize' => array('argc' => '-xvf', 'toSpec' => '--to-stdout|wc -c', 'regex' => '/^.+(?:\r\n|\n|\r)[^\r\n0-9]*([0-9]+)[^\r\n]*$/s', 'replace' => '$1'));
}
}
@@ -1419,5 +1419,24 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver
return ($this->stripos($name, $this->doSearchCurrentQuery['q']) === false) ? false : true;
}
/**
* Creates a symbolic link
*
* @param string $target The target
* @param string $link The link
*
* @return boolean ( result of symlink() )
*/
protected function localFileSystemSymlink($target, $link)
{
$res = false;
$errlev = error_reporting();
error_reporting($errlev ^ E_WARNING);
if ($res = symlink(realpath($target), $link)) {
$res = is_readable($link);
}
error_reporting($errlev);
return $res;
}
} // END class