private function removeDir($d)
    {
        $list = $d->listDir();
        if ($list === null) {
            $list = [];
        }

        foreach ($list as $s) {
            $f = new PhingFile($d, $s);
            if ($f->isDirectory()) {
                $this->removeDir($f);
            } else {
                $this->log("Deleting " . $f->__toString(), $this->verbosity);
                try {
                    $f->delete();
                } catch (Exception $e) {
                    $message = "Unable to delete file " . $f->__toString() . ": " . $e->getMessage();
                    if ($this->failonerror) {
                        throw new BuildException($message);
                    } else {
                        $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
                    }
                }
            }
        }
        $this->log("Deleting directory " . $d->getAbsolutePath(), $this->verbosity);
        try {
            $d->delete();
        } catch (Exception $e) {
            $message = "Unable to delete directory " . $d->__toString() . ": " . $e->getMessage();
            if ($this->failonerror) {
                throw new BuildException($message);
            } else {
                $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
            }
        }
    }