elFinder\elFinderVolumeDriver::allowCreate PHP Method

allowCreate() protected method

Return true if file with given name can be created in given folder.
Author: Dmitry (dio) Levashov
protected allowCreate ( string $dir, string $name ) : boolean
$dir string parent dir path
$name string new file name
return boolean
    protected function allowCreate($dir, $name)
    {
        $path = $this->_joinPath($dir, $name);
        $perm = null;
        if ($this->access) {
            if (is_array($this->access)) {
                $obj = $this->access[0];
                $method = $this->access[1];
                $perm = $obj->{$method}('write', $path, $this->options['accessControlData'], $this);
            } else {
                $func = $this->access;
                $perm = $func('write', $path, $this->options['accessControlData'], $this);
            }
            if ($perm !== null) {
                return !!$perm;
            }
        }
        $testPath = $this->separator . $this->_relpath($path);
        for ($i = 0, $c = count($this->attributes); $i < $c; $i++) {
            $attrs = $this->attributes[$i];
            if (isset($attrs['write']) && isset($attrs['pattern']) && preg_match($attrs['pattern'], $testPath)) {
                $perm = $attrs['write'];
            }
        }
        return $perm === null ? true : $perm;
    }