private function deleteDir(PhingFile $d)
    {
        $list = $d->listDir();
        if ($list === null) {
            return; // on an io error list() can return null
        }

        foreach ($list as $fname) {
            $f = new PhingFile($d, $fname);
            if ($f->isDirectory()) {
                $this->deleteDir($f);
            } else {
                throw new BuildException("UNEXPECTED ERROR - The file " . $f->getAbsolutePath() . " should not exist!");
            }
        }

        $this->log("Deleting directory " . $d->getPath(), $this->verbosity);
        try {
            $d->delete();
        } catch (Exception $e) {
            $this->logError("Unable to delete directory " . $d->__toString() . ": " . $e->getMessage());
        }
    }