elFinder\elFinderVolumeDriver::duplicate PHP Method

duplicate() public method

Create file copy with suffix "copy number" and return its info
Author: Dmitry (dio) Levashov
public duplicate ( string $hash, string $suffix = 'copy' ) : array | false
$hash string file hash
$suffix string suffix to add to file name
return array | false
    public function duplicate($hash, $suffix = 'copy')
    {
        if ($this->commandDisabled('duplicate')) {
            return $this->setError(elFinder::ERROR_COPY, '#' . $hash, elFinder::ERROR_PERM_DENIED);
        }
        if (($file = $this->file($hash)) == false) {
            return $this->setError(elFinder::ERROR_COPY, elFinder::ERROR_FILE_NOT_FOUND);
        }
        $path = $this->decode($hash);
        $dir = $this->_dirname($path);
        $name = $this->uniqueName($dir, $this->_basename($path), ' ' . $suffix . ' ');
        if (!$this->allowCreate($dir, $name)) {
            return $this->setError(elFinder::ERROR_PERM_DENIED);
        }
        return ($path = $this->copy($path, $dir, $name)) == false ? false : $this->stat($path);
    }