本文整理汇总了C++中FilePath::extensionLowerCase方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::extensionLowerCase方法的具体用法?C++ FilePath::extensionLowerCase怎么用?C++ FilePath::extensionLowerCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::extensionLowerCase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fmt
std::string CssUrlFilter::toBase64Url(const boost::cmatch& match)
{
// is this a local file?
std::string urlRef = match[1];
FilePath urlPath = basePath_.childPath(urlRef);
std::string ext = urlPath.extensionLowerCase();
if (urlPath.exists() && (ext == ".ttf" || ext == ".otf"))
{
std::string fontBase64;
Error error = core::base64::encode(urlPath, &fontBase64);
if (!error)
{
// return base64 encoded font
std::string type = (ext == ".ttf") ? "truetype" : "opentype";
boost::format fmt("url(data:font/%1%;base64,%2%)");
return boost::str(fmt % type % fontBase64);
}
else
{
LOG_ERROR(error);
return match[0];
}
}
else
{
return match[0];
}
}
示例2: readPresentation
bool readPresentation(SlideDeck* pSlideDeck,
std::string* pSlides,
std::string* pInitActions,
std::string* pSlideActions,
std::map<std::string,std::string>* pVars,
std::string* pErrMsg)
{
// look for slides and knit if we need to
FilePath rmdFile = presentation::state::filePath();
std::string ext = rmdFile.extensionLowerCase();
if (rmdFile.exists() && (ext != ".md"))
{
if (!performKnit(rmdFile, pErrMsg))
return false;
}
// look for slides markdown
FilePath slidesFile = rmdFile.parent().childPath(rmdFile.stem() + ".md");
if (!slidesFile.exists())
{
*pErrMsg = slidesFile.absolutePath() + " not found";
return false;
}
// parse the slides
Error error = pSlideDeck->readSlides(slidesFile);
if (error)
{
LOG_ERROR(error);
*pErrMsg = error.summary();
return false;
}
// render the slides
std::string revealConfig;
error = presentation::renderSlides(*pSlideDeck,
pSlides,
&revealConfig,
pInitActions,
pSlideActions);
if (error)
{
LOG_ERROR(error);
*pErrMsg = error.summary();
return false;
}
// build template variables
std::map<std::string,std::string>& vars = *pVars;
vars["title"] = pSlideDeck->title();
vars["slides"] = *pSlides;
vars["slides_css"] = resourceFiles().get("presentation/slides.css");
vars["r_highlight"] = resourceFiles().get("r_highlight.html");
vars["reveal_config"] = revealConfig;
vars["preamble"] = pSlideDeck->preamble();
return true;
}
示例3: handleFileUploadRequest
void handleFileUploadRequest(const http::Request& request,
http::Response* pResponse)
{
// response content type must always be text/html to be handled
// properly by the browser/gwt on the client side
pResponse->setContentType("text/html");
// get fields
const http::File& file = request.uploadedFile("file");
std::string targetDirectory = request.formFieldValue("targetDirectory");
// first validate that we got the required fields
if (file.name.empty() || targetDirectory.empty())
{
json::setJsonRpcError(json::errc::ParamInvalid, pResponse);
return;
}
// now validate the file
if ( !validateUploadedFile(file, pResponse) )
return ;
// form destination path
FilePath destDir = module_context::resolveAliasedPath(targetDirectory);
FilePath destPath = destDir.childPath(file.name);
// establish whether this is a zip file and create appropriate temp file path
bool isZip = destPath.extensionLowerCase() == ".zip";
FilePath tempFilePath = module_context::tempFile("upload",
isZip ? "zip" : "bin");
// attempt to write the temp file
Error saveError = core::writeStringToFile(tempFilePath, file.contents);
if (saveError)
{
LOG_ERROR(saveError);
json::setJsonRpcError(saveError, pResponse);
return;
}
// detect any potential overwrites
json::Array overwritesJson;
if (isZip)
{
Error error = detectZipFileOverwrites(tempFilePath,
destDir,
&overwritesJson);
if (error)
{
LOG_ERROR(error);
json::setJsonRpcError(error, pResponse);
return;
}
}
else
{
if (destPath.exists())
overwritesJson.push_back(module_context::createFileSystemItem(destPath));
}
// set the upload information as the result
json::Object uploadTokenJson;
uploadTokenJson[kUploadFilename] = file.name;
uploadTokenJson[kUploadedTempFile] = tempFilePath.absolutePath();
uploadTokenJson[kUploadTargetDirectory] = destDir.absolutePath();
json::Object uploadJson;
uploadJson["token"] = uploadTokenJson;
uploadJson["overwrites"] = overwritesJson;
json::setJsonRpcResult(uploadJson, pResponse);
}