本文整理汇总了C++中FilePath::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::parent方法的具体用法?C++ FilePath::parent怎么用?C++ FilePath::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isHTMLWidgetPath
bool isHTMLWidgetPath(const FilePath& filePath)
{
// parent of parent must be session temp dir
// (this is required because of the way we copy/restore
// widget directories during suspend/resume)
FilePath parentDir = filePath.parent();
if (parentDir.parent() != module_context::tempDir())
return false;
// it is a widget!
return true;
}
示例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: parseBibtexLog
Error parseBibtexLog(const FilePath& logFilePath, LogEntries* pLogEntries)
{
boost::regex re("^(.*)---line ([0-9]+) of file (.*)$");
// get the lines
std::vector<std::string> lines;
Error error = ::core::readStringVectorFromFile(logFilePath, &lines, false);
if (error)
return error;
// look for error messages
for (std::vector<std::string>::const_iterator it = lines.begin();
it != lines.end();
it++)
{
boost::smatch match;
if (regex_match(*it, match, re))
{
pLogEntries->push_back(
LogEntry(
logFilePath,
(it - lines.begin()) + 1,
LogEntry::Error,
texFilePath(match[3], logFilePath.parent()),
boost::lexical_cast<int>(match[2]),
match[1]));
}
}
return Success();
}
示例4: getSlideNavigationForFile
Error getSlideNavigationForFile(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
// get param
std::string file;
Error error = json::readParam(request.params, 0, &file);
if (error)
return error;
FilePath filePath = module_context::resolveAliasedPath(file);
// read code
std::string code;
error = core::readStringFromFile(filePath,
&code,
string_utils::LineEndingPosix);
if (error)
return error;
// get slide navigation
json::Object slideNavigationJson;
error = getSlideNavigation(code, filePath.parent(), &slideNavigationJson);
if (error)
return error;
pResponse->setResult(slideNavigationJson);
return Success();
}
示例5: onFileChanged
void onFileChanged(FilePath sourceFilePath)
{
// ignore file changes while Packrat is running
if (s_runningPackratAction != PACKRAT_ACTION_NONE)
return;
// we only care about mutations to files in the Packrat library directory
// (and packrat.lock)
FilePath libraryPath =
projects::projectContext().directory().complete(kPackratLibPath);
if (sourceFilePath.filename() == kPackratLockfile)
{
PACKRAT_TRACE("detected change to lockfile " << sourceFilePath);
checkHashes(HASH_TYPE_LOCKFILE, HASH_STATE_OBSERVED, onLockfileUpdate);
}
else if (sourceFilePath.isWithin(libraryPath) &&
(sourceFilePath.isDirectory() ||
sourceFilePath.filename() == "DESCRIPTION"))
{
// ignore changes in the RStudio-managed manipulate and rstudio
// directories and the files within them
if (sourceFilePath.filename() == "manipulate" ||
sourceFilePath.filename() == "rstudio" ||
sourceFilePath.parent().filename() == "manipulate" ||
sourceFilePath.parent().filename() == "rstudio")
{
return;
}
PACKRAT_TRACE("detected change to library file " << sourceFilePath);
checkHashes(HASH_TYPE_LIBRARY, HASH_STATE_OBSERVED, onLibraryUpdate);
}
}
示例6: 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;
}
示例7: listFiles
Error listFiles(const json::JsonRpcRequest& request, json::JsonRpcResponse* pResponse)
{
// get args
std::string path;
bool monitor;
Error error = json::readParams(request.params, &path, &monitor);
if (error)
return error;
FilePath targetPath = module_context::resolveAliasedPath(path) ;
json::Object result;
// if this includes a request for monitoring
core::json::Array jsonFiles;
if (monitor)
{
// always stop existing if we have one
s_filesListingMonitor.stop();
// install a monitor only if we aren't already covered by the project monitor
if (!session::projects::projectContext().isMonitoringDirectory(targetPath))
{
error = s_filesListingMonitor.start(targetPath, &jsonFiles);
if (error)
return error;
}
else
{
error = FilesListingMonitor::listFiles(targetPath, &jsonFiles);
if (error)
return error;
}
}
else
{
error = FilesListingMonitor::listFiles(targetPath, &jsonFiles);
if (error)
return error;
}
result["files"] = jsonFiles;
bool browseable = true;
#ifndef _WIN32
// on *nix systems, see if browsing above this path is possible
error = core::system::isFileReadable(targetPath.parent(), &browseable);
if (error && !core::isPathNotFoundError(error))
LOG_ERROR(error);
#endif
result["is_parent_browseable"] = browseable;
pResponse->setResult(result);
return Success();
}
示例8: setChunkDefs
Error setChunkDefs(const std::string& docPath, const std::string& docId,
std::time_t docTime, const json::Array& newDefs)
{
// create JSON object wrapping
json::Object chunkDefs;
chunkDefs[kChunkDefs] = newDefs;
chunkDefs[kChunkDocWriteTime] = static_cast<boost::int64_t>(docTime);
// ensure we have a place to write the sidecar file
FilePath defFile = chunkDefinitionsPath(docPath, docId,
notebookCtxId());
// if there are no old chunk definitions and we aren't adding any new ones,
// no work to do
if (!defFile.exists() && newDefs.size() < 1)
return Success();
// we're going to write something; make sure the parent folder exists
Error error = defFile.parent().ensureDirectory();
if (error)
return error;
// get the old set of chunk IDs so we can clean up any not in the new set
// of chunks
std::vector<std::string> chunkIds;
json::Value oldDefs;
std::string oldContent;
error = getChunkDefs(docPath, docId, notebookCtxId(), NULL,
&oldDefs);
if (error)
LOG_ERROR(error);
else if (oldDefs.type() == json::ArrayType)
{
if (oldDefs.get_array() == newDefs)
{
// definitions not changing; no work to do
return Success();
}
cleanChunks(chunkCacheFolder(docPath, docId),
oldDefs.get_array(), newDefs);
}
std::ostringstream oss;
json::write(chunkDefs, oss);
error = writeStringToFile(defFile, oss.str());
if (error)
{
LOG_ERROR(error);
return error;
}
return Success();
}
示例9: isHTMLWidgetPath
bool isHTMLWidgetPath(const FilePath& filePath)
{
// get the session temp dir real path; needed since the file path above is
// also a real path--e.g. on OS X, it refers to /private/tmp rather than
// /tmp
FilePath tempDir;
Error error = core::system::realPath(module_context::tempDir(), &tempDir);
if (error)
LOG_ERROR(error);
// parent of parent must be session temp dir
// (this is required because of the way we copy/restore
// widget directories during suspend/resume)
FilePath parentDir = filePath.parent();
if (parentDir.parent() != tempDir)
return false;
// it is a widget!
return true;
}
示例10: setPath
void FileDialog::setPath(const FilePath &path) {
if(path.isDirectory()) {
m_dir_path = path;
m_edit_box->setText({});
}
else {
m_dir_path = path.parent();
m_edit_box->setText(toUTF32Checked(path.fileName()));
}
updateList();
updateButtons();
}
示例11: resolvePandocPath
void Options::resolvePandocPath(const FilePath& resourcePath,
std::string* pPath)
{
if (*pPath == kDefaultPandocPath)
{
FilePath path = resourcePath.parent().complete("MacOS/pandoc");
*pPath = path.absolutePath();
}
else
{
resolvePath(resourcePath, pPath);
}
}
示例12: installPath
// installation path
Error installPath(const std::string& relativeToExecutable,
const char * argv0,
FilePath* pInstallPath)
{
// get executable path
FilePath executablePath;
Error error = system::executablePath(argv0, &executablePath);
if (error)
return error;
// fully resolve installation path relative to executable
FilePath installPath = executablePath.parent().complete(relativeToExecutable);
return realPath(installPath.absolutePath(), pInstallPath);
}
示例13: initializeStreamDir
inline Error initializeStreamDir(const FilePath& streamDir)
{
Error error = streamDir.ensureDirectory();
if (error)
return error;
error = changeFileMode(streamDir.parent(),
system::EveryoneReadWriteExecuteMode);
if (error)
return error;
return changeFileMode(streamDir,
system::EveryoneReadWriteExecuteMode);
}
示例14: resolvePostbackPath
void Options::resolvePostbackPath(const FilePath& resourcePath,
std::string* pPath)
{
// On OSX we keep the postback scripts over in the MacOS directory
// rather than in the Resources directory -- make this adjustment
// when the default postback path has been passed
if (*pPath == kDefaultPostbackPath)
{
FilePath path = resourcePath.parent().complete("MacOS/postback/rpostback");
*pPath = path.absolutePath();
}
else
{
resolvePath(resourcePath, pPath);
}
}
示例15: rs_pathInfo
SEXP rs_pathInfo(SEXP pathSEXP)
{
try
{
// validate
if (r::sexp::length(pathSEXP) != 1)
{
throw r::exec::RErrorException(
"must pass a single file to get path info for");
}
std::string path;
Error error = r::sexp::extract(pathSEXP, &path);
if (error)
throw r::exec::RErrorException(r::endUserErrorMessage(error));
// resolve aliased path
FilePath filePath = module_context::resolveAliasedPath(path);
if (filePath.empty())
throw r::exec::RErrorException("invalid path: " + path);
// create path info vector (use json repsesentation to force convertion
// to VECSXP rather than STRSXP)
json::Object pathInfo;
pathInfo["path"] = filePath.absolutePath();
std::string parent = filePath.absolutePath();
FilePath parentPath = filePath.parent();
if (!parentPath.empty())
parent = parentPath.absolutePath();
pathInfo["directory"] = parent;
pathInfo["name"] = filePath.filename();
pathInfo["stem"] = filePath.stem();
pathInfo["extension"] = filePath.extension();
// return it
r::sexp::Protect rProtect;
return r::sexp::create(pathInfo, &rProtect);
}
catch(r::exec::RErrorException e)
{
r::exec::error(e.message());
}
CATCH_UNEXPECTED_EXCEPTION
return R_NilValue;
}