public static function rename($name, $newName, $overwrite = TRUE)
{
if (!$overwrite && file_exists($newName)) {
throw new Nette\InvalidStateException("File or directory '{$newName}' already exists.");
} elseif (!file_exists($name)) {
throw new Nette\IOException("File or directory '{$name}' not found.");
} else {
static::createDir(dirname($newName));
static::delete($newName);
if (!@rename($name, $newName)) {
// @ is escalated to exception
throw new Nette\IOException("Unable to rename file or directory '{$name}' to '{$newName}'.");
}
}
}
/** * @param string $oldIdGallery * @param string $newIdGallery * @param string $oldLang * @param string $newLang */ public function renameGallery($oldIdGallery, $newIdGallery, $oldLang, $newLang) { b($oldIdGallery, 'oI'); b($newIdGallery, 'nI'); b($oldLang, 'oL'); b($newLang, 'nL'); FileSystem::rename(galleryPath . $oldIdGallery . '_' . $oldLang, galleryPath . $newIdGallery . '_' . $newLang); }