elFinder\elFinderVolumeDriver::remove PHP Method

remove() protected method

Remove file/ recursive remove dir
Author: Dmitry (dio) Levashov
protected remove ( string $path, boolean $force = false ) : boolean
$path string file path
$force boolean try to remove even if file locked
return boolean
    protected function remove($path, $force = false)
    {
        $stat = $this->stat($path);
        $stat['realpath'] = $path;
        $this->rmTmb($stat);
        $this->clearcache();
        if (empty($stat)) {
            return $this->setError(elFinder::ERROR_RM, $this->_path($path), elFinder::ERROR_FILE_NOT_FOUND);
        }
        if (!$force && !empty($stat['locked'])) {
            return $this->setError(elFinder::ERROR_LOCKED, $this->_path($path));
        }
        if ($stat['mime'] == 'directory') {
            foreach ($this->_scandir($path) as $p) {
                $name = $this->_basename($p);
                if ($name != '.' && $name != '..' && !$this->remove($p)) {
                    return false;
                }
            }
            if (!$this->_rmdir($path)) {
                return $this->setError(elFinder::ERROR_RM, $this->_path($path));
            }
        } else {
            if (!$this->_unlink($path)) {
                return $this->setError(elFinder::ERROR_RM, $this->_path($path));
            }
        }
        $this->removed[] = $stat;
        return true;
    }