本文整理汇总了C++中FilePath::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::empty方法的具体用法?C++ FilePath::empty怎么用?C++ FilePath::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get
// TODO(brettw): this function does not handle long paths (filename > MAX_PATH)
// characters). This isn't supported very well by Windows right now, so it is
// moot, but we should keep this in mind for the future.
// static
bool PathService::Get(int key, FilePath* result)
{
PathData* path_data = GetPathData();
DCHECK(path_data);
DCHECK(result);
DCHECK_GE(key, base::DIR_CURRENT);
// special case the current directory because it can never be cached
if(key == base::DIR_CURRENT)
{
return base::GetCurrentDirectory(result);
}
if(GetFromCache(key, result))
{
return true;
}
if(GetFromOverrides(key, result))
{
return true;
}
FilePath path;
// search providers for the requested path
// NOTE: it should be safe to iterate here without the lock
// since RegisterProvider always prepends.
Provider* provider = path_data->providers;
while(provider)
{
if(provider->func(key, &path))
{
break;
}
DCHECK(path.empty()) << "provider should not have modified path";
provider = provider->next;
}
if(path.empty())
{
return false;
}
AddToCache(key, path);
*result = path;
return true;
}
示例2: GetPathToBinary
void GetPathToBinary(FilePath& exePath)
{
#if defined(OS_WIN)
exePath = FilePath::FromWStringHack(CommandLine::ForCurrentProcess()->program());
exePath = exePath.DirName();
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
#elif defined(OS_POSIX)
if (ShouldHaveDirectoryService()) {
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
NS_ASSERTION(directoryService, "Expected XPCOM to be available");
if (directoryService) {
nsCOMPtr<nsIFile> greDir;
nsresult rv = directoryService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(greDir));
if (NS_SUCCEEDED(rv)) {
nsCString path;
greDir->GetNativePath(path);
exePath = FilePath(path.get());
#ifdef MOZ_WIDGET_COCOA
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_BUNDLE);
#endif
}
}
}
if (exePath.empty()) {
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
exePath = exePath.DirName();
}
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
#endif
}
示例3: saveResource
void ResourcesSerializationUtil::saveResource( Filesystem& filesystem, const Resource* savedResource, const FilePath& differentSavePath )
{
if ( !savedResource )
{
return;
}
// see if the user doesn't want to save the resource under a different name
FilePath savedResourcePath;
if ( !differentSavePath.empty() )
{
savedResourcePath = differentSavePath;
}
else
{
savedResourcePath = savedResource->getFilePath();
}
std::string extension = savedResourcePath.extractExtension();
std::ios_base::openmode accessMode = Resource::getFileAccessMode( extension );
File* file = filesystem.open( savedResourcePath, std::ios_base::out | accessMode );
if ( !file )
{
return;
}
// save the resource
OutFileStream outStream( file );
ReflectionSaver saver( outStream );
saver.save( savedResource );
}
示例4: FilePath
//static
void
GeckoChildProcessHost::GetPathToBinary(FilePath& exePath)
{
if (ShouldHaveDirectoryService()) {
MOZ_ASSERT(gGREPath);
#ifdef OS_WIN
exePath = FilePath(char16ptr_t(gGREPath));
#else
nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREPath), path);
exePath = FilePath(path.get());
#endif
#ifdef MOZ_WIDGET_COCOA
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_BUNDLE);
#endif
}
if (exePath.empty()) {
#ifdef OS_WIN
exePath = FilePath::FromWStringHack(CommandLine::ForCurrentProcess()->program());
#else
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
#endif
exePath = exePath.DirName();
}
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
}
示例5: 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;
}
示例6: getTerminalOptions
Error getTerminalOptions(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
json::Object optionsJson;
FilePath terminalPath;
#if defined(_WIN32)
// if we are using git bash then return its path
if (git::isGitEnabled() && userSettings().vcsUseGitBash())
{
FilePath gitExePath = git::detectedGitExePath();
if (!gitExePath.empty())
terminalPath = gitExePath.parent().childPath("sh.exe");
}
#elif defined(__APPLE__)
// do nothing (we always launch Terminal.app)
#else
// auto-detection (+ overridable by a setting)
terminalPath = userSettings().vcsTerminalPath();
if (terminalPath.empty())
terminalPath = detectedTerminalPath();
#endif
// append shell paths as appropriate
std::string extraPathEntries;
ammendShellPaths(&extraPathEntries);
optionsJson["terminal_path"] = terminalPath.absolutePath();
optionsJson["working_directory"] =
module_context::shellWorkingDirectory().absolutePath();
optionsJson["extra_path_entries"] = extraPathEntries;
pResponse->setResult(optionsJson);
return Success();
}
示例7: runSvn
Error runSvn(const ShellArgs& args,
const FilePath& workingDir,
bool redirectStdErrToStdOut,
core::system::ProcessResult* pResult)
{
core::system::ProcessOptions options = procOptions();
if (!workingDir.empty())
options.workingDir = workingDir;
options.redirectStdErrToStdOut = redirectStdErrToStdOut;
Error error = core::system::runCommand(svn() << args.args(),
options,
pResult);
return error;
}
示例8: copy
/*! concatenates two filepaths to this/other */
FilePath operator +(const FilePath& other) const {
if (m_FilePath.empty()) {
return other;
} else {
if(other.empty()) {
return m_FilePath;
}
FilePath copy(*this);
if(other.m_FilePath.front() != PATH_SEPARATOR) {
copy.m_FilePath += PATH_SEPARATOR;
}
copy.m_FilePath += other.m_FilePath;
return copy;
}
}
示例9: initialize
void FileLock::initialize(FilePath locksConfPath)
{
if (locksConfPath.empty())
locksConfPath = FilePath(kLocksConfPath);
Settings settings;
if (locksConfPath.exists())
{
Error error = settings.initialize(locksConfPath);
if (error)
LOG_ERROR(error);
}
FileLock::initialize(settings);
}
示例10: initializeWithFile
bool initializeWithFile(const FilePath& filePath,
int width,
int height,
bool displayListon,
DeviceContext* pDC)
{
// initialize file info
if (filePath.empty())
pDC->targetPath = tempFile("png");
else
pDC->targetPath = filePath;
pDC->width = width;
pDC->height = height;
return true;
}
示例11: FilePath
//static
void
GeckoChildProcessHost::GetPathToBinary(FilePath& exePath)
{
if (ShouldHaveDirectoryService()) {
MOZ_ASSERT(gGREBinPath);
#ifdef OS_WIN
exePath = FilePath(char16ptr_t(gGREBinPath));
#elif MOZ_WIDGET_COCOA
nsCOMPtr<nsIFile> childProcPath;
NS_NewLocalFile(nsDependentString(gGREBinPath), false,
getter_AddRefs(childProcPath));
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
childProcPath->AppendNative(NS_LITERAL_CSTRING("plugin-container.app"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("Contents"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("MacOS"));
nsCString tempCPath;
childProcPath->GetNativePath(tempCPath);
exePath = FilePath(tempCPath.get());
#else
nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path);
exePath = FilePath(path.get());
#endif
}
if (exePath.empty()) {
#ifdef OS_WIN
exePath = FilePath::FromWStringHack(CommandLine::ForCurrentProcess()->program());
#else
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
#endif
exePath = exePath.DirName();
}
#ifdef MOZ_WIDGET_ANDROID
exePath = exePath.AppendASCII("lib");
// We must use the PIE binary on 5.0 and higher
const char* processName = mozilla::AndroidBridge::Bridge()->GetAPIVersion() >= 21 ?
MOZ_CHILD_PROCESS_NAME_PIE : MOZ_CHILD_PROCESS_NAME;
exePath = exePath.AppendASCII(processName);
#else
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
#endif
}
示例12: createConsoleProc
core::Error createConsoleProc(const ShellArgs& args,
const FilePath& outputFile,
const boost::optional<FilePath>& workingDir,
const std::string& caption,
bool requiresSsh,
bool dialog,
bool enqueueRefreshOnExit,
boost::shared_ptr<ConsoleProcess>* ppCP)
{
core::system::ProcessOptions options = procOptions(requiresSsh);
if (!workingDir)
options.workingDir = s_workingDir;
else if (!workingDir.get().empty())
options.workingDir = workingDir.get();
// NOTE: we use runCommand style process creation on both windows and posix
// so that we can redirect standard output to a file -- this works on
// windows because we are not specifying options.detachProcess (not
// necessary because ConsoleProcess specifies options.createNewConsole
// which overrides options.detachProcess)
// build command
std::string command = svn() << args.args();
// redirect stdout to a file
if (!outputFile.empty())
options.stdOutFile = outputFile;
// create the process
using namespace session::console_process;
*ppCP = ConsoleProcess::create(command,
options,
caption,
dialog,
InteractionPossible,
kDefaultMaxOutputLines);
if (enqueueRefreshOnExit)
(*ppCP)->onExit().connect(boost::bind(&enqueueRefreshEvent));
return Success();
}
示例13: initialize
core::Error initialize()
{
git::initialize();
svn::initialize();
// http endpoints
using boost::bind;
using namespace module_context;
ExecBlock initBlock ;
initBlock.addFunctions()
(bind(registerRpcMethod, "vcs_clone", vcsClone));
Error error = initBlock.execute();
if (error)
return error;
// If VCS is disabled, or we're not in a project, do nothing
const projects::ProjectContext& projContext = projects::projectContext();
FilePath workingDir = projContext.directory();
if (!session::options().allowVcs() || !userSettings().vcsEnabled() || workingDir.empty())
return Success();
// If Git or SVN was explicitly specified, choose it if valid
projects::RProjectVcsOptions vcsOptions;
if (projContext.hasProject())
{
Error vcsError = projContext.readVcsOptions(&vcsOptions);
if (vcsError)
LOG_ERROR(vcsError);
}
if (vcsOptions.vcsOverride == kVcsIdNone)
{
return Success();
}
else if (vcsOptions.vcsOverride == git::kVcsId)
{
if (git::isGitInstalled() && git::isGitDirectory(workingDir))
return git::initializeGit(workingDir);
return Success();
}
else if (vcsOptions.vcsOverride == svn::kVcsId)
{
if (svn::isSvnInstalled() && svn::isSvnDirectory(workingDir))
return svn::initializeSvn(workingDir);
return Success();
}
if (git::isGitInstalled() && git::isGitDirectory(workingDir))
{
return git::initializeGit(workingDir);
}
else if (svn::isSvnInstalled() && svn::isSvnDirectory(workingDir))
{
return svn::initializeSvn(workingDir);
}
else
{
return Success(); // none specified or detected
}
}
示例14: defined
//static
void
GeckoChildProcessHost::GetPathToBinary(FilePath& exePath, GeckoProcessType processType)
{
if (sRunSelfAsContentProc &&
processType == GeckoProcessType_Content) {
#if defined(OS_WIN)
wchar_t exePathBuf[MAXPATHLEN];
if (!::GetModuleFileNameW(nullptr, exePathBuf, MAXPATHLEN)) {
MOZ_CRASH("GetModuleFileNameW failed (FIXME)");
}
exePath = FilePath::FromWStringHack(exePathBuf);
#elif defined(OS_POSIX)
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
#else
# error Sorry; target OS not supported yet.
#endif
return;
}
if (ShouldHaveDirectoryService()) {
MOZ_ASSERT(gGREBinPath);
#ifdef OS_WIN
exePath = FilePath(char16ptr_t(gGREBinPath));
#elif MOZ_WIDGET_COCOA
nsCOMPtr<nsIFile> childProcPath;
NS_NewLocalFile(nsDependentString(gGREBinPath), false,
getter_AddRefs(childProcPath));
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
childProcPath->AppendNative(NS_LITERAL_CSTRING("plugin-container.app"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("Contents"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("MacOS"));
nsCString tempCPath;
childProcPath->GetNativePath(tempCPath);
exePath = FilePath(tempCPath.get());
#else
nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path);
exePath = FilePath(path.get());
#endif
}
if (exePath.empty()) {
#ifdef OS_WIN
exePath = FilePath::FromWStringHack(CommandLine::ForCurrentProcess()->program());
#else
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
#endif
exePath = exePath.DirName();
}
#ifdef MOZ_WIDGET_ANDROID
exePath = exePath.AppendASCII("lib");
// We must use the PIE binary on 5.0 and higher
const char* processName = mozilla::AndroidBridge::Bridge()->GetAPIVersion() >= 21 ?
MOZ_CHILD_PROCESS_NAME_PIE : MOZ_CHILD_PROCESS_NAME;
exePath = exePath.AppendASCII(processName);
#else
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
#endif
}
示例15: getRPrefs
Error getRPrefs(const json::JsonRpcRequest& request,
json::JsonRpcResponse* pResponse)
{
// get general prefs
json::Object generalPrefs;
generalPrefs["save_action"] = userSettings().saveAction();
generalPrefs["load_rdata"] = userSettings().loadRData();
generalPrefs["rprofile_on_resume"] = userSettings().rProfileOnResume();
generalPrefs["initial_working_dir"] = module_context::createAliasedPath(
userSettings().initialWorkingDirectory());
// get history prefs
json::Object historyPrefs;
historyPrefs["always_save"] = userSettings().alwaysSaveHistory();
historyPrefs["remove_duplicates"] = userSettings().removeHistoryDuplicates();
// get packages prefs
json::Object packagesPrefs;
packagesPrefs["use_devtools"] = userSettings().useDevtools();
packagesPrefs["cran_mirror"] = toCRANMirrorJson(
userSettings().cranMirror());
packagesPrefs["use_internet2"] = userSettings().useInternet2();
packagesPrefs["bioconductor_mirror"] = toBioconductorMirrorJson(
userSettings().bioconductorMirror());
packagesPrefs["cleanup_after_check_success"] = userSettings().cleanupAfterRCmdCheck();
packagesPrefs["viewdir_after_check_failure"] = userSettings().viewDirAfterRCmdCheck();
packagesPrefs["hide_object_files"] = userSettings().hideObjectFiles();
// get projects prefs
json::Object projectsPrefs;
projectsPrefs["restore_last_project"] = userSettings().alwaysRestoreLastProject();
// get source control prefs
json::Object sourceControlPrefs;
sourceControlPrefs["vcs_enabled"] = userSettings().vcsEnabled();
FilePath gitExePath = userSettings().gitExePath();
if (gitExePath.empty())
gitExePath = git::detectedGitExePath();
sourceControlPrefs["git_exe_path"] = gitExePath.absolutePath();
FilePath svnExePath = userSettings().svnExePath();
if (svnExePath.empty())
svnExePath = svn::detectedSvnExePath();
sourceControlPrefs["svn_exe_path"] = svnExePath.absolutePath();
FilePath terminalPath = userSettings().vcsTerminalPath();
if (terminalPath.empty())
terminalPath = detectedTerminalPath();
sourceControlPrefs["terminal_path"] = terminalPath.absolutePath();
sourceControlPrefs["use_git_bash"] = userSettings().vcsUseGitBash();
FilePath sshKeyDir = modules::source_control::defaultSshKeyDir();
FilePath rsaSshKeyPath = sshKeyDir.childPath("id_rsa");
sourceControlPrefs["rsa_key_path"] =
module_context::createAliasedPath(rsaSshKeyPath);
sourceControlPrefs["have_rsa_key"] = rsaSshKeyPath.exists();
// get compile pdf prefs
json::Object compilePdfPrefs;
compilePdfPrefs["clean_output"] = userSettings().cleanTexi2DviOutput();
compilePdfPrefs["enable_shell_escape"] = userSettings().enableLaTeXShellEscape();
// initialize and set result object
json::Object result;
result["general_prefs"] = generalPrefs;
result["history_prefs"] = historyPrefs;
result["packages_prefs"] = packagesPrefs;
result["projects_prefs"] = projectsPrefs;
result["source_control_prefs"] = sourceControlPrefs;
result["compile_pdf_prefs"] = compilePdfPrefs;
result["spelling_prefs_context"] =
session::modules::spelling::spellingPrefsContextAsJson();
pResponse->setResult(result);
return Success();
}