/** * {@inheritdoc} */ public function resolveLocal(Pathname $pathname, &$localAdapter, &$local) { $path = $pathname->full(); do { if (isset($this->mounts[$path])) { $localAdapter = $this->mounts[$path]; $local = substr($pathname->full(), strlen($path)); return $this; } } while ('/' !== ($path = Util::dirname($path))); throw new AdapterException('No mount found for ' . $pathname->full()); }
protected function prepareFilters(PathnameIterator $iterator = null) { if ($this->bitmask === null || $this->globs === null || $this->callables === null || $this->globSearchPatterns === null) { if ($iterator !== null) { $this->bitmask = $iterator->bitmask; $this->globs = $iterator->globs; $this->callables = $iterator->callables; $this->globSearchPatterns = $iterator->globSearchPatterns; } else { $this->bitmask = null; $this->globs = array(); $this->callables = array(); $this->globSearchPatterns = array(); $this->evaluateFilters($this->filters); // fallback bitmask, list all if ($this->bitmask === null) { $this->bitmask = File::LIST_ALL; } else { if ($this->bitmask === File::LIST_HIDDEN || $this->bitmask === File::LIST_VISIBLE || $this->bitmask === (File::LIST_HIDDEN | File::LIST_VISIBLE) || $this->bitmask === (File::LIST_HIDDEN | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_VISIBLE | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_HIDDEN | File::LIST_VISIBLE | File::LIST_RECURSIVE)) { $this->bitmask |= File::LIST_FILES; $this->bitmask |= File::LIST_DIRECTORIES; $this->bitmask |= File::LIST_LINKS; $this->bitmask |= File::LIST_OPAQUE; } else { if ($this->bitmask === File::LIST_FILES || $this->bitmask === File::LIST_DIRECTORIES || $this->bitmask === (File::LIST_FILES | File::LIST_DIRECTORIES) || $this->bitmask === (File::LIST_FILES | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_DIRECTORIES | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_FILES | File::LIST_DIRECTORIES | File::LIST_RECURSIVE)) { $this->bitmask |= File::LIST_HIDDEN; $this->bitmask |= File::LIST_VISIBLE; $this->bitmask |= File::LIST_LINKS; $this->bitmask |= File::LIST_OPAQUE; } else { if ($this->bitmask === File::LIST_LINKS || $this->bitmask === File::LIST_OPAQUE || $this->bitmask === (File::LIST_LINKS | File::LIST_OPAQUE) || $this->bitmask === (File::LIST_LINKS | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_OPAQUE | File::LIST_RECURSIVE) || $this->bitmask === (File::LIST_LINKS | File::LIST_OPAQUE | File::LIST_RECURSIVE)) { $this->bitmask |= File::LIST_HIDDEN; $this->bitmask |= File::LIST_VISIBLE; } else { if ($this->bitmask === File::LIST_RECURSIVE) { $this->bitmask |= File::LIST_ALL; } } } } } // prepare globs foreach ($this->globs as $index => $glob) { $parts = explode('/', $glob); // path based globs if (count($parts) > 1) { $max = count($parts) - 2; $path = ''; for ($i = 0; $i < $max; $i++) { $path .= ($path ? '/' : '') . $parts[$i]; $globSearchPatterns[] = Util::normalizePath('*/' . $this->pathname->full() . '/' . $path); } $this->globs[$index] = Util::normalizePath('*/' . $this->pathname->full() . '/' . $glob); } else { $this->globs[$index] = $glob; } } } } }
public function __construct(Pathname $pathname, $code = 0, $previous = null) { if ($code === 0) { $code = FilesystemException::FILE_NOT_FOUND; } parent::__construct(sprintf('File %s not found!', $pathname->full()), $code, $previous); $this->pathname = $pathname; }
public function __construct(Pathname $pathname, $code = 0, $previous = null) { if ($code === 0) { $code = FilesystemException::NOT_A_FILE; } parent::__construct(sprintf('Pathname %s is not a file!', $pathname->full()), $code, $previous); $this->pathname = $pathname; }
public function __construct(Pathname $pathname, $code = 0, \Exception $previous = null) { if ($code === 0) { $code = FilesystemException::NOT_A_DIRECTORY; } parent::__construct(sprintf('Pathname %s is not a directory!', $pathname->full()), $code, $previous); $this->pathname = $pathname; }
/** * Return the parent file object. * May return null if called on the root "/" node. * * @return File|null * * @api */ public function getParent() { if ($this->pathname->full() != '/') { return $this->filesystem->getFile($this->getDirname()); } return null; }
public function __construct(Pathname $srcPathname, Pathname $dstPathname, $code = 0, $previous = null) { parent::__construct(sprintf('Could not replace directory %s with file %s!', $dstPathname->full(), $srcPathname->full()), $code, $previous); $this->srcPathname = $srcPathname; $this->dstPathname = $dstPathname; }
/** * {@inheritdoc} */ public function resolveLocal(Pathname $pathname, &$localAdapter, &$local) { $localAdapter = $this; $local = $pathname->full(); }
/** * Create new empty file. * * @param string $pathname The full abstracted pathname * @param string $local The adapter local path * @param bool $parents * @return void * @throws FileStateException If the file does already exists * @throws AdapterException If the access to the underlying filesystem fails * due to technical reasons like connection problems or timeouts */ public function createFile(Pathname $pathname, $parents) { $stat = $this->getConnection()->stat($this->getBasepath() . $pathname->local()); if ($stat) { if (!$stat['type'] == NET_SFTP_TYPE_REGULAR) { throw new AdapterException(sprintf('Pathname %s already exists and is not a file', $pathname->full())); } } // TODO handle $parents if (!$this->getConnection()->put($this->getBasepath() . $pathname->local(), '')) { throw new AdapterException(sprintf('Could not create file %s', $pathname->full())); } }