public function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false)
    {
        // ensure that parent dir of dest file exists!
        $parent = $destFile->getParentFile();
        if ($parent !== null) {
            if (!$parent->exists()) {
                $parent->mkdirs();
            }
        }

        if ($overwrite || !$destFile->exists() || $destFile->lastModified() < $sourceFile->lastModified()) {
            if ($destFile->exists()) {
                try {
                    $destFile->delete();
                } catch (Exception $e) {
                    throw new BuildException(
                        "Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage()
                    );
                }
            }
        }

        $sourceFile->renameTo($destFile);
    }