/** * Open directory handle * * @param string $path * @param int $options * * @return boolean */ public function dir_opendir($path, $options) { $this->openFile($path); if ($this->file->isDirectory()) { $this->directoryIterator = $this->file->getIterator(); return true; } return false; }
/** * Delete a file or directory. * * @param File $file the file * * @param bool $recursive * * @return bool */ public function delete($file, $recursive = false, $force = false) { // TODO: invalidate cache after delete? if ($file->isDirectory()) { if ($recursive) { /** @var File $file */ foreach ($file->ls() as $file) { if (!$file->delete(true, $force)) { return false; } } } else { if ($file->count() > 0) { return false; } } return $this->ftpDelete($file); } else { if (!$file->isWritable()) { if ($force) { $file->setMode(0666); } else { return false; } } return $this->ftpDelete($file); } }
/** * Apply bitmask filters on current file. * * @param \Filicious\File $file * * @return bool */ protected function applyBitmaskFilters(File $file) { $basename = $file->getBasename(); if (!($this->bitmask & File::LIST_HIDDEN) && $basename[0] == '.' || !($this->bitmask & File::LIST_VISIBLE) && $basename[0] != '.' || !($this->bitmask & File::LIST_FILES) && $file->isFile() || !($this->bitmask & File::LIST_DIRECTORIES) && $file->isDirectory() || !($this->bitmask & File::LIST_LINKS) && $file->isLink() || !($this->bitmask & File::LIST_OPAQUE) && !$file->isLink()) { return false; } return true; }