本文整理汇总了C++中FileSystem::Rename方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::Rename方法的具体用法?C++ FileSystem::Rename怎么用?C++ FileSystem::Rename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::Rename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Move
bool AssetImporter::Move(const String& newPath)
{
FileSystem* fs = GetSubsystem<FileSystem>();
if (newPath == asset_->path_)
return false;
String oldPath = asset_->path_;
String oldName = asset_->name_;
String pathName, newName, ext;
SplitPath(newPath, pathName, newName, ext);
// rename asset first, ahead of the filesystem watcher, so the assetdatabase doesn't see a new asset
asset_->name_ = newName;
asset_->path_ = newPath;
// first rename the .asset file
if (!fs->Rename(oldPath + ".asset", newPath + ".asset"))
{
asset_->name_ = oldName;
asset_->path_ = oldPath;
LOGERRORF("Unable to rename asset: %s to %s", GetNativePath(oldPath + ".asset").CString(), GetNativePath(newPath + ".asset").CString());
return false;
}
// now rename the asset file itself
if (!fs->Rename(oldPath, newPath))
{
asset_->name_ = oldName;
asset_->path_ = oldPath;
// restore .asset
fs->Rename(newPath + ".asset", oldPath + ".asset");
LOGERRORF("Unable to rename: %s to %s", GetNativePath(oldPath).CString(), GetNativePath(newPath).CString());
return false;
}
return true;
}