public function dir($path)
{
$this->originDir = getcwd();
$this->dir = realpath(dirname($path));
$this->filter = basename($path);
if (is_dir($this->dir)) {
if (is_readable($this->dir)) {
chdir($this->dir);
} else {
throw new NotEnoughPrivileges('read', fileperms($this->dir), $this->dir);
}
} else {
throw new PathIsNotDir($this->dir);
}
$this->files = glob($this->filter);
foreach ($this->files as $file) {
if (!is_readable($file)) {
throw new NotEnoughPrivileges('read', fileperms($file), $file);
}
}
chdir($this->originDir);
return $this;
}