本文整理匯總了PHP中PhingFile::renameTo方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhingFile::renameTo方法的具體用法?PHP PhingFile::renameTo怎麽用?PHP PhingFile::renameTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhingFile
的用法示例。
在下文中一共展示了PhingFile::renameTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renameFile
/**
* Attempts to rename a file from a source to a destination.
* If overwrite is set to true, this method overwrites existing file
* even if the destination file is newer.
* Otherwise, the source f
* ile is renamed only if the destination file #
* is older than it.
*/
private function renameFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite)
{
$renamed = true;
// ensure that parent dir of dest file exists!
$parent = $destFile->getParentFile();
if ($parent !== null) {
if (!$parent->exists()) {
$parent->mkdirs();
}
}
if ($destFile->exists()) {
try {
$destFile->delete();
} catch (Exception $e) {
throw new BuildException("Unable to remove existing file " . $destFile->__toString() . ": " . $e->getMessage());
}
}
$renamed = $sourceFile->renameTo($destFile);
return $renamed;
}