本文整理汇总了C++中FilePath::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::copy方法的具体用法?C++ FilePath::copy怎么用?C++ FilePath::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copySourceFile
bool copySourceFile(const FilePath& sourceDir,
const FilePath& destDir,
int level,
const FilePath& sourceFilePath)
{
// compute the target path
std::string relativePath = sourceFilePath.relativePath(sourceDir);
FilePath targetPath = destDir.complete(relativePath);
// if the copy item is a directory just create it
if (sourceFilePath.isDirectory())
{
Error error = targetPath.ensureDirectory();
if (error)
LOG_ERROR(error);
}
// otherwise copy it
else
{
Error error = sourceFilePath.copy(targetPath);
if (error)
LOG_ERROR(error);
}
return true;
}
示例2: copyFile
// IN: String sourcePath, String targetPath
Error copyFile(const ::core::json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
// read params
std::string sourcePath, targetPath;
bool overwrite;
Error error = json::readParams(request.params,
&sourcePath,
&targetPath,
&overwrite);
if (error)
return error;
FilePath targetFilePath = module_context::resolveAliasedPath(targetPath);
// make sure the target path doesn't exist
if (targetFilePath.exists())
{
if (overwrite)
{
Error error = targetFilePath.remove();
if (error)
{
LOG_ERROR(error);
return fileExistsError(ERROR_LOCATION);
}
}
else
{
return fileExistsError(ERROR_LOCATION);
}
}
// compute the source file path
FilePath sourceFilePath = module_context::resolveAliasedPath(sourcePath);
// copy directories recursively
Error copyError ;
if (sourceFilePath.isDirectory())
{
// create the target directory
Error error = targetFilePath.ensureDirectory();
if (error)
return error ;
// iterate over the source
copyError = sourceFilePath.childrenRecursive(
boost::bind(copySourceFile, sourceFilePath, targetFilePath, _1, _2));
}
else
{
copyError = sourceFilePath.copy(targetFilePath);
}
// check quota after copies
quotas::checkQuotaStatus();
// return error status
return copyError;
}
示例3: provision
std::string provision(const std::string& title, const FilePath& filePath)
{
// calculate content path
std::string contentFile = core::system::generateUuid(false) +
filePath.extension();
FilePath contentPath = contentUrlPath().complete(contentFile);
// copy the file
Error error = filePath.copy(contentPath);
if (error)
LOG_ERROR(error);
// calculate and return content url
return buildContentUrl(title, contentFile);
}
示例4: add
Error HunspellCustomDictionaries::add(const FilePath& dicPath) const
{
// validate .dic extension
if (!dicPath.hasExtensionLowerCase(".dic"))
{
return systemError(boost::system::errc::invalid_argument,
ERROR_LOCATION);
}
// remove existing with same name
std::string name = dicPath.stem();
Error error = remove(name);
if (error)
LOG_ERROR(error);
// add it
return dicPath.copy(dictionaryPath(name));
}