本文整理汇总了C++中FilePath::childPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::childPath方法的具体用法?C++ FilePath::childPath怎么用?C++ FilePath::childPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::childPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getProjectUserDataDir
FilePath getProjectUserDataDir(const ErrorLocation& location)
{
// get the project directory
FilePath projectDir = projects::projectContext().directory();
// presume that the project dir is the data dir then check
// for a .Ruserdata directory as an alternative
FilePath dataDir = projectDir;
FilePath ruserdataDir = projectDir.childPath(".Ruserdata");
if (ruserdataDir.exists())
{
// create user-specific subdirectory if necessary
FilePath userDir = ruserdataDir.childPath(core::system::username());
Error error = userDir.ensureDirectory();
if (!error)
{
dataDir = userDir;
}
else
{
core::log::logError(error, location);
}
}
// return the data dir
return dataDir;
}
示例2: detectBuildType
std::string detectBuildType(const FilePath& projectFilePath,
const RProjectBuildDefaults& buildDefaults,
RProjectConfig* pConfig)
{
FilePath projectDir = projectFilePath.parent();
if (r_util::isPackageDirectory(projectDir))
{
setBuildPackageDefaults("", buildDefaults ,pConfig);
}
else if (projectDir.childPath("pkg/DESCRIPTION").exists())
{
setBuildPackageDefaults("pkg", buildDefaults, pConfig);
}
else if (projectDir.childPath("Makefile").exists())
{
pConfig->buildType = kBuildTypeMakefile;
pConfig->makefilePath = "";
}
else if (isWebsiteDirectory(projectDir))
{
pConfig->buildType = kBuildTypeWebsite;
pConfig->websitePath = "";
}
else
{
pConfig->buildType = kBuildTypeNone;
}
return pConfig->buildType;
}
示例3: detectSystemRVersion
bool RVersionsScanner::detectSystemRVersion(core::r_util::RVersion* pVersion,
std::string* pErrMsg)
{
// return cached version if we have it
if (!systemVersion_.empty())
{
*pVersion = systemVersion_;
return true;
}
// check for which R override
FilePath rWhichRPath;
if (!whichROverride_.empty())
rWhichRPath = FilePath(whichROverride_);
// if it's a directory then see if we can find the script
if (rWhichRPath.isDirectory())
{
FilePath rScriptPath = rWhichRPath.childPath("bin/R");
if (rScriptPath.exists())
rWhichRPath = rScriptPath;
}
// attempt to detect R version
bool result = detectRVersion(rWhichRPath, pVersion, pErrMsg);
// if we detected it then cache it
if (result)
systemVersion_ = *pVersion;
// return result
return result;
}
示例4: read
Error RPackageInfo::read(const FilePath& packageDir)
{
// parse DCF file
FilePath descFilePath = packageDir.childPath("DESCRIPTION");
if (!descFilePath.exists())
return core::fileNotFoundError(descFilePath, ERROR_LOCATION);
std::string errMsg;
std::map<std::string,std::string> fields;
Error error = text::parseDcfFile(descFilePath, true, &fields, &errMsg);
if (error)
return error;
// Package field
std::map<std::string,std::string>::const_iterator it;
it = fields.find("Package");
if (it != fields.end())
name_ = it->second;
else
return fieldNotFoundError(descFilePath, "Package", ERROR_LOCATION);
// Version field
it = fields.find("Version");
if (it != fields.end())
version_ = it->second;
else
return fieldNotFoundError(descFilePath, "Version", ERROR_LOCATION);
// Linking to field
it = fields.find("LinkingTo");
if (it != fields.end())
linkingTo_ = it->second;
return Success();
}
示例5: read
Error RPackageInfo::read(const FilePath& packageDir)
{
// parse DCF file
FilePath descFilePath = packageDir.childPath("DESCRIPTION");
if (!descFilePath.exists())
return core::fileNotFoundError(descFilePath, ERROR_LOCATION);
std::string errMsg;
std::map<std::string,std::string> fields;
Error error = text::parseDcfFile(descFilePath, true, &fields, &errMsg);
if (error)
return error;
error = readField(fields, "Package", &name_, descFilePath, ERROR_LOCATION);
if (error) return error;
error = readField(fields, "Version", &version_, descFilePath, ERROR_LOCATION);
if (error) return error;
readField(fields, "Depends", &depends_);
readField(fields, "Imports", &imports_);
readField(fields, "Suggests", &suggests_);
readField(fields, "LinkingTo", &linkingTo_);
readField(fields, "SystemRequirements", &systemRequirements_);
readField(fields, "Type", &type_, kPackageType);
return Success();
}
示例6: handleHelpHomeRequest
void handleHelpHomeRequest(const core::http::Request& request,
const std::string& jsCallbacks,
core::http::Response* pResponse)
{
// get the resource path
FilePath helpResPath = options().rResourcesPath().complete("help_resources");
// resolve the file reference
std::string path = http::util::pathAfterPrefix(request,
"/help/doc/home/");
// if it's empty then this is the root template
if (path.empty())
{
std::map<std::string,std::string> variables;
variables["js_callbacks"] = jsCallbacks;
text::TemplateFilter templateFilter(variables);
pResponse->setNoCacheHeaders();
pResponse->setFile(helpResPath.childPath("index.htm"),
request,
templateFilter);
}
// otherwise it's just a file reference
else
{
FilePath filePath = helpResPath.complete(path);
pResponse->setCacheableFile(filePath, request);
}
}
示例7: ActiveSessions
explicit ActiveSessions(const FilePath& rootStoragePath)
{
storagePath_ = rootStoragePath.childPath("session-storage");
Error error = storagePath_.ensureDirectory();
if (error)
LOG_ERROR(error);
}
示例8: projectFromDirectory
FilePath projectFromDirectory(const FilePath& directoryPath)
{
// first use simple heuristic of a case sentitive match between
// directory name and project file name
FilePath projectFile = directoryPath.childPath(
directoryPath.filename() + ".Rproj");
if (projectFile.exists())
return projectFile;
// didn't satisfy it with simple check so do scan of directory
std::vector<FilePath> children;
Error error = directoryPath.children(&children);
if (error)
{
LOG_ERROR(error);
return FilePath();
}
// build a vector of children with .rproj extensions. at the same
// time allow for a case insensitive match with dir name and return that
std::string projFileLower = string_utils::toLower(projectFile.filename());
std::vector<FilePath> rprojFiles;
for (std::vector<FilePath>::const_iterator it = children.begin();
it != children.end();
++it)
{
if (!it->isDirectory() && (it->extensionLowerCase() == ".rproj"))
{
if (string_utils::toLower(it->filename()) == projFileLower)
return *it;
else
rprojFiles.push_back(*it);
}
}
// if we found only one rproj file then return it
if (rprojFiles.size() == 1)
{
return rprojFiles.at(0);
}
// more than one, take most recent
else if (rprojFiles.size() > 1 )
{
projectFile = rprojFiles.at(0);
for (std::vector<FilePath>::const_iterator it = rprojFiles.begin();
it != rprojFiles.end();
++it)
{
if (it->lastWriteTime() > projectFile.lastWriteTime())
projectFile = *it;
}
return projectFile;
}
// didn't find one
else
{
return FilePath();
}
}
示例9: collectFirstRunDocs
std::vector<std::string> collectFirstRunDocs(const FilePath& projectFile)
{
// docs to return
std::vector<std::string> docs;
// get the scratch path
FilePath scratchPath;
Error error = computeScratchPaths(projectFile, &scratchPath, nullptr);
if (error)
{
LOG_ERROR(error);
return docs;
}
// check for first run file
FilePath firstRunDocsPath = scratchPath.childPath(kFirstRunDocs);
if (firstRunDocsPath.exists())
{
Error error = core::readStringVectorFromFile(firstRunDocsPath, &docs);
if (error)
LOG_ERROR(error);
// remove since this is a one-time only thing
firstRunDocsPath.remove();
}
return docs;
}
示例10: moveFiles
// IN: Array<String> paths, String targetPath
Error moveFiles(const ::core::json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
json::Array files;
std::string targetPath;
Error error = json::readParams(request.params, &files, &targetPath);
if (error)
return error ;
// extract vector of FilePath
std::vector<FilePath> filePaths ;
Error extractError = extractFilePaths(files, &filePaths) ;
if (extractError)
return extractError ;
// create FilePath for target directory
FilePath targetDirPath = module_context::resolveAliasedPath(targetPath);
if (!targetDirPath.isDirectory())
return Error(json::errc::ParamInvalid, ERROR_LOCATION);
// move the files
for (std::vector<FilePath>::const_iterator
it = filePaths.begin();
it != filePaths.end();
++it)
{
// move the file
FilePath targetPath = targetDirPath.childPath(it->filename()) ;
Error moveError = it->move(targetPath) ;
if (moveError)
return moveError ;
}
return Success() ;
}
示例11:
FileLogWriter::FileLogWriter(const std::string& programIdentity,
int logLevel,
const FilePath& logDir)
: programIdentity_(programIdentity),
logLevel_(logLevel)
{
logDir.ensureDirectory();
logFile_ = logDir.childPath(programIdentity + ".log");
rotatedLogFile_ = logDir.childPath(programIdentity + ".rotated.log");
if (!logFile_.exists())
{
// swallow errors -- we can't log so it doesn't matter
core::appendToFile(logFile_, "");
}
}
示例12:
FileLogWriter::FileLogWriter(const std::string& programIdentity,
int logLevel,
const FilePath& logDir)
: programIdentity_(programIdentity),
logLevel_(logLevel)
{
logDir.ensureDirectory();
logFile_ = logDir.childPath(programIdentity + ".log");
}
示例13: uniqueFilePath
FilePath uniqueFilePath(const FilePath& parent, const std::string& prefix)
{
// try up to 100 times then fallback to a uuid
for (int i=0; i<100; i++)
{
// get a shortened uuid
std::string shortentedUuid = core::system::generateShortenedUuid();
// form full path
FilePath uniqueDir = parent.childPath(prefix + shortentedUuid);
// return if it doesn't exist
if (!uniqueDir.exists())
return uniqueDir;
}
// if we didn't succeed then return prefix + uuid
return parent.childPath(prefix + core::system::generateUuid(false));
}
示例14: userSettingsPath
FilePath userSettingsPath(const FilePath& userHomeDirectory,
const std::string& appName)
{
std::string lower = appName;
boost::to_lower(lower);
FilePath path = userHomeDirectory.childPath("." + lower);
Error error = path.ensureDirectory();
if (error)
{
LOG_ERROR(error);
}
return path;
}
示例15: initialize
Error PersistentState::initialize()
{
serverMode_ = (session::options().programMode() ==
kSessionProgramModeServer);
// always the same so that we can supporrt a restart of
// the session without reloading the client page
desktopClientId_ = "33e600bb-c1b1-46bf-b562-ab5cba070b0e";
FilePath scratchPath = module_context::scopedScratchPath();
activeClientIdPath_ = scratchPath.childPath(kActiveClientId);
FilePath statePath = scratchPath.complete("persistent-state");
return settings_.initialize(statePath);
}