function getDirectoryScanner(Project $p)
{
if ($this->isReference()) {
$o = $this->getRef($p);
return $o->getDirectoryScanner($p);
}
if ($this->dir === null) {
throw new BuildException("No directory specified for fileset.");
}
if (!$this->dir->exists()) {
throw new BuildException("Directory " . $this->dir->getAbsolutePath() . " not found.");
}
if (!$this->dir->isDirectory()) {
throw new BuildException($this->dir->getAbsolutePath() . " is not a directory.");
}
$ds = new DirectoryScanner();
$this->setupDirectoryScanner($ds, $p);
$ds->scan();
return $ds;
}