本文整理汇总了C++中FilePath::isDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::isDirectory方法的具体用法?C++ FilePath::isDirectory怎么用?C++ FilePath::isDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::isDirectory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDefaultWorkingDirectory
FilePath getDefaultWorkingDirectory()
{
// calculate using user settings
FilePath defaultWorkingDir = userSettings().initialWorkingDirectory();
FilePath sessionDefaultWorkingDir = FilePath(session::options().defaultWorkingDir());
// return it if it exists, otherwise use the
// session specified value if it exists
// otherwise, use the default user home path
if (defaultWorkingDir.exists() && defaultWorkingDir.isDirectory())
return defaultWorkingDir;
else if (sessionDefaultWorkingDir.exists() && sessionDefaultWorkingDir.isDirectory())
return sessionDefaultWorkingDir;
else
return session::options().userHomePath();
}
示例2: 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);
}
}
示例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: getInitialWorkingDirectory
FilePath getInitialWorkingDirectory()
{
// check for a project
if (projects::projectContext().hasProject())
{
return projects::projectContext().directory();
}
// check for working dir in project none
else if (options().sessionScope().isProjectNone())
{
return getActiveSessionInitialWorkingDirectory();
}
// see if there is an override from the environment (perhaps based
// on a folder drag and drop or other file association)
FilePath workingDirPath = session::options().initialWorkingDirOverride();
if (workingDirPath.exists() && workingDirPath.isDirectory())
{
return workingDirPath;
}
else
{
return getActiveSessionInitialWorkingDirectory();
}
}
示例5: 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() ;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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();
}
示例9: checkForExternalEdit
Error checkForExternalEdit(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
pResponse->setSuppressDetectChanges(true);
// params
std::string id ;
Error error = json::readParams(request.params, &id);
if (error)
return error;
boost::shared_ptr<SourceDocument> pDoc(new SourceDocument()) ;
error = source_database::get(id, pDoc);
if (error)
return error ;
json::Object result;
result["modified"] = false;
result["deleted"] = false;
// Only check if this document has ever been saved
if (!pDoc->path().empty())
{
FilePath docFile = module_context::resolveAliasedPath(pDoc->path());
if (!docFile.exists() || docFile.isDirectory())
{
result["deleted"] = true;
pDoc->setDirty(true);
error = source_database::put(pDoc);
if (error)
return error;
}
else
{
std::time_t lastWriteTime ;
pDoc->checkForExternalEdit(&lastWriteTime);
if (lastWriteTime)
{
FilePath filePath = module_context::resolveAliasedPath(pDoc->path()) ;
json::Object fsItem = module_context::createFileSystemItem(filePath);
result["item"] = fsItem;
result["modified"] = true;
}
}
}
pResponse->setResult(result);
return Success();
}
示例10: handleFilesRequest
void handleFilesRequest(const http::Request& request,
http::Response* pResponse)
{
Options& options = session::options();
if (options.programMode() != kSessionProgramModeServer)
{
pResponse->setError(http::status::NotFound,
request.uri() + " not found");
return;
}
// get prefix and uri
std::string prefix = "/files/";
std::string uri = request.uri();
// validate the uri
if (prefix.length() >= uri.length() || // prefix longer than uri
uri.find(prefix) != 0 || // uri doesn't start with prefix
uri.find("..") != std::string::npos) // uri has inavlid char sequence
{
pResponse->setError(http::status::NotFound,
request.uri() + " not found");
return;
}
// compute path to file
int prefixLen = prefix.length();
std::string relativePath = http::util::urlDecode(uri.substr(prefixLen));
if (relativePath.empty())
{
pResponse->setError(http::status::NotFound, request.uri() + " not found");
return;
}
// complete path to file
FilePath filePath = module_context::userHomePath().complete(relativePath);
// no directory listing available
if (filePath.isDirectory())
{
pResponse->setError(http::status::NotFound,
"No listing available for " + request.uri());
return;
}
pResponse->setNoCacheHeaders();
pResponse->setFile(filePath, request);
}
示例11: getInitialWorkingDirectory
FilePath getInitialWorkingDirectory()
{
// check for a project
if (projects::projectContext().hasProject())
{
return projects::projectContext().directory();
}
// check for working dir in project none
else if (options().sessionScope().isProjectNone())
{
// if this is the initial session then use the default working directory
// (reset initial to false so this is one shot thing)
using namespace module_context;
if (activeSession().initial())
{
activeSession().setInitial(false);
return getDefaultWorkingDirectory();
}
FilePath workingDirPath = module_context::resolveAliasedPath(
module_context::activeSession().workingDir());
if (workingDirPath.exists())
return workingDirPath;
else
return getDefaultWorkingDirectory();
}
// see if there is an override from the environment (perhaps based
// on a folder drag and drop or other file association)
FilePath workingDirPath = session::options().initialWorkingDirOverride();
if (workingDirPath.exists() && workingDirPath.isDirectory())
{
return workingDirPath;
}
else
{
// if not then just return default working dir
return getDefaultWorkingDirectory();
}
}