/** * {@inheritDoc} */ public function delete(Filesystem $remote, array $options = array()) { if (!$remote instanceof File) { throw new \InvalidArgumentException(sprintf("Invalid filesystem given, expected instance of File got %s", get_class($remote))); } if (null === $this->manager->findFileByFile($remote)) { throw new DirectoryException(sprintf("Could not locate file %s", $remote->getRealpath())); } $this->wrapper->delete($remote->getRealpath()); return true; }
/** * {@inheritDoc} */ public function create(Filesystem $remote, array $options = array()) { if (!$remote instanceof Directory) { throw new \InvalidArgumentException(sprintf("Invalid filesystem given, expected instance of Directory got %s", get_class($remote))); } if (!isset($options[FTP::RECURSIVE]) || true !== $options[FTP::RECURSIVE]) { throw new \InvalidArgumentException("Invalid option given. Expected true as FTP::RECURSIVE parameter"); } $full = ltrim($remote->getRealpath(), '/'); $parts = explode('/', $full); $path = ''; foreach ($parts as $part) { $path = sprintf("%s/%s", $path, $part); if (null === $this->manager->findDirectoryByName($path) && !$this->wrapper->mkdir($path)) { throw new DirectoryException(sprintf("Could not create directory %s", $path)); } } return true; }
/** * {@inheritDoc} */ public function getCwd() { return $this->manager->getCwd(); }
/** * Deletes directories in a directory * * @param Directory $path /remote/path/ * @param array $options Deleter options */ private function deleteDirectories(Directory $path, array $options = array()) { foreach ($this->manager->findDirectories($path) as $dir) { $this->delete($dir, $options); } }