本文整理汇总了C++中FilePath::isWithin方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::isWithin方法的具体用法?C++ FilePath::isWithin怎么用?C++ FilePath::isWithin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::isWithin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: getScriptRunCommand
Error getScriptRunCommand(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
// params
std::string interpreter, path;
Error error = json::readParams(request.params, &interpreter, &path);
if (error)
return error ;
FilePath filePath = module_context::resolveAliasedPath(path);
// use as minimal a path as possible
FilePath currentPath = module_context::safeCurrentPath();
if (filePath.isWithin(currentPath))
{
path = filePath.relativePath(currentPath);
if (interpreter.empty())
{
#ifndef _WINDOWS
if (path.find_first_of('/') == std::string::npos)
path = "./" + path;
}
#endif
}
else
{
path = filePath.absolutePath();
}
// quote if necessary
if (path.find_first_of(' ') != std::string::npos)
path = "\\\"" + path + "\\\"";
// if there's no interpreter then we may need to do a chmod
#ifndef _WINDOWS
if (interpreter.empty())
{
error = r::exec::RFunction(
"system",
"chmod +x " +
string_utils::utf8ToSystem(path)).call();
if (error)
return error;
}
#endif
// now build and return the command
std::string command;
if (interpreter.empty())
command = path;
else
command = interpreter + " " + path;
command = "system(\"" + command + "\")";
pResponse->setResult(command);
return Success();
}
示例3: rs_viewer
SEXP rs_viewer(SEXP urlSEXP, SEXP heightSEXP)
{
try
{
// get the height parameter (0 if null)
int height = 0;
if (!r::sexp::isNull(heightSEXP))
height = r::sexp::asInteger(heightSEXP);
// transform the url to a localhost:<port>/session one if it's
// a path to a file within the R session temporary directory
std::string url = r::sexp::safeAsString(urlSEXP);
if (!boost::algorithm::starts_with(url, "http"))
{
// get the path to the tempdir and the file
FilePath tempDir = module_context::tempDir();
FilePath filePath = module_context::resolveAliasedPath(url);
// canoncialize paths for comparison
Error error = core::system::realPath(tempDir, &tempDir);
if (error)
LOG_ERROR(error);
error = core::system::realPath(filePath, &filePath);
if (error)
LOG_ERROR(error);
// if it's in the temp dir and we're running R >= 2.14 then
// we can serve it via the help server, otherwise we need
// to show it in an external browser
if (filePath.isWithin(tempDir) && r::util::hasRequiredVersion("2.14"))
{
// calculate the relative path
std::string path = filePath.relativePath(tempDir);
// add to history and treat as a widget if appropriate
if (isHTMLWidgetPath(filePath))
{
// add it to our history
viewerHistory().add(module_context::ViewerHistoryEntry(path));
// view it
viewerNavigate(viewerHistory().current().url(),
height,
true,
true);
}
else
{
viewerNavigate(module_context::sessionTempDirUrl(path),
height,
false,
true);
}
}
else
{
module_context::showFile(filePath);
}
}
else
{
// in desktop mode make sure we have the right version of httpuv
if (options().programMode() == kSessionProgramModeDesktop)
{
if (!module_context::isPackageVersionInstalled("httpuv", "1.2"))
{
module_context::consoleWriteError("\nWARNING: To run "
"applications within the RStudio Viewer pane you need to "
"install the latest version of the httpuv package from "
"CRAN (version 1.2 or higher is required).\n\n");
}
}
// navigate the viewer
viewerNavigate(url, height, false, true);
}
}
CATCH_UNEXPECTED_EXCEPTION
return R_NilValue;
}
示例4: isMonitoringDirectory
bool ProjectContext::isMonitoringDirectory(const FilePath& dir) const
{
return hasProject() && hasFileMonitor() && dir.isWithin(directory());
}