本文整理汇总了C++中FilePath::AppendASCII方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::AppendASCII方法的具体用法?C++ FilePath::AppendASCII怎么用?C++ FilePath::AppendASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::AppendASCII方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: 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);
}
示例3: handleINT
void handleINT(int sig) {
FilePath homedirpath;
PathService::Get(chrome::DIR_USER_DATA,&homedirpath);
FilePath child = homedirpath.AppendASCII("SingletonLock");
unlink(child.value().c_str());
exit(-sig);
}
示例4: 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
}
示例5: ReadProfiles
void ChromiumProfileImporter::ReadProfiles(vector<ChromeProfileInfo> *cp,
FilePath profileDirectory) {
FilePath profileFileName = profileDirectory.AppendASCII("Local State");
if (!PathExists(profileFileName))
return;
string input;
ReadFileToString(profileFileName, &input);
JSONReader reader;
scoped_ptr<Value> root(reader.ReadToValue(input));
DictionaryValue* dict = NULL;
if (!root->GetAsDictionary(&dict)) {
return;
}
const Value* roots;
if (!dict->Get("profile", &roots)) {
return;
}
const DictionaryValue* roots_d_value =
static_cast<const DictionaryValue*>(roots);
const Value* vInfoCache;
const DictionaryValue* vDictValue;
if (roots_d_value->Get("info_cache", &vInfoCache)) {
vInfoCache->GetAsDictionary(&vDictValue);
for (DictionaryValue::Iterator it(*vDictValue); !it.IsAtEnd(); it.Advance()){
const Value* child_copy = &it.value();
string profileName = it.key();
const DictionaryValue* roots_sd_value =
static_cast<const DictionaryValue*>(&it.value());
ChromeProfileInfo prof;
const Value* namVal;
if (roots_sd_value->Get("name", &namVal)) {
string16 displayName;
namVal->GetAsString(&displayName);
prof.profileDisplayName = displayName;
} else {
prof.profileDisplayName = base::UTF8ToUTF16(profileName);
}
prof.profileName = profileName;
cp->push_back(prof);
}
}
}
示例6: 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
}
示例7: cmdLine
bool
GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
{
// FIXME/cjones: make this work from non-IO threads, too
// We rely on the fact that InitializeChannel() has already been processed
// on the IO thread before this point is reached.
if (!GetChannel()) {
return false;
}
base::ProcessHandle process;
// send the child the PID so that it can open a ProcessHandle back to us.
// probably don't want to do this in the long run
char pidstring[32];
PR_snprintf(pidstring, sizeof(pidstring) - 1,
"%ld", base::Process::Current().pid());
const char* const childProcessType =
XRE_ChildProcessTypeToString(mProcessType);
//--------------------------------------------------
#if defined(OS_POSIX)
// For POSIX, we have to be extremely anal about *not* using
// std::wstring in code compiled with Mozilla's -fshort-wchar
// configuration, because chromium is compiled with -fno-short-wchar
// and passing wstrings from one config to the other is unsafe. So
// we split the logic here.
FilePath exePath;
#ifdef OS_LINUX
base::environment_map newEnvVars;
#endif
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
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 OS_LINUX
newEnvVars["LD_LIBRARY_PATH"] = path.get();
#endif
}
else {
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
exePath = exePath.DirName();
}
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
// remap the IPC socket fd to a well-known int, as the OS does for
// STDOUT_FILENO, for example
int srcChannelFd, dstChannelFd;
channel().GetClientFileDescriptorMapping(&srcChannelFd, &dstChannelFd);
mFileMap.push_back(std::pair<int,int>(srcChannelFd, dstChannelFd));
// no need for kProcessChannelID, the child process inherits the
// other end of the socketpair() from us
std::vector<std::string> childArgv;
childArgv.push_back(exePath.value());
childArgv.insert(childArgv.end(), aExtraOpts.begin(), aExtraOpts.end());
childArgv.push_back(pidstring);
childArgv.push_back(childProcessType);
#if defined(MOZ_CRASHREPORTER)
int childCrashFd, childCrashRemapFd;
if (!CrashReporter::CreateNotificationPipeForChild(
&childCrashFd, &childCrashRemapFd))
return false;
if (0 <= childCrashFd) {
mFileMap.push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd));
// "true" == crash reporting enabled
childArgv.push_back("true");
}
else {
// "false" == crash reporting disabled
childArgv.push_back("false");
}
#endif
base::LaunchApp(childArgv, mFileMap,
#ifdef OS_LINUX
newEnvVars,
#endif
false, &process);
//--------------------------------------------------
#elif defined(OS_WIN)
FilePath exePath =
FilePath::FromWStringHack(CommandLine::ForCurrentProcess()->program());
exePath = exePath.DirName();
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
//.........这里部分代码省略.........
示例8: init
//.........这里部分代码省略.........
mRenderViewHostFactory.reset(new MemoryRenderViewHostFactory);
// mNotificationService=new NotificationService();
// ChildProcess* coreProcess=new ChildProcess;
// coreProcess->set_main_thread(new ChildThread);
g_browser_process->SetApplicationLocale("en-US");
ResourceBundle::InitSharedInstance("en-US");// FIXME: lookup locale
// We only load the theme dll in the browser process.
net::CookieMonster::EnableFileScheme();
browser_process->profile_manager();
browser_process->db_thread();
browser_process->file_thread();
browser_process->process_launcher_thread();
browser_process->cache_thread();
browser_process->io_thread();
// Initialize histogram synchronizer system. This is a singleton and is used
// for posting tasks via NewRunnableMethod. Its deleted when it goes out of
// scope. Even though NewRunnableMethod does AddRef and Release, the object
// will not be deleted after the Task is executed.
mHistogramSynchronizer= (new HistogramSynchronizer());
browser::RegisterLocalState(g_browser_process->local_state());
ProfileManager* profile_manager = browser_process->profile_manager();
homedirpath = homedirpath.Append(profile_manager->GetCurrentProfileDir());
{
//std::cout << "Profile path: " << homedirpath.value() << std::endl;
FilePath prefs_path (ProfileManager::GetProfilePrefsPath(homedirpath));
FILE *fp = file_util::OpenFile(prefs_path, "a");
file_util::CloseFile(fp);
FilePath history_path (homedirpath);
history_path = history_path.Append(chrome::kHistoryFilename);
//std::cout << " Profile exists: " << ProfileManager::IsProfile(homedirpath) << std::endl;
}
mProf = profile_manager->GetProfile(homedirpath, false);
if (!mProf) {
mProcessSingleton.reset();
return false;
}
mProf->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, false);
mProf->GetPrefs()->RegisterStringPref(prefs::kSafeBrowsingClientKey, "");
mProf->GetPrefs()->RegisterStringPref(prefs::kSafeBrowsingWrappedKey, "");
mProf->InitExtensions();
PrefService* user_prefs = mProf->GetPrefs();
DCHECK(user_prefs);
// browser_process->local_state()->SetString(prefs::kApplicationLocale,std::wstring());
mProcessSingleton->Create();
mDNSPrefetch.reset(new chrome_browser_net::PredictorInit(
user_prefs,
browser_process->local_state(),
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePreconnect)));
BrowserURLHandler::InitURLHandlers();
// From chrome/browser/browser_main.cc
// Register our global network handler for chrome:// and
// chrome-extension:// URLs.
ChromeURLDataManagerBackend::Register();
/*
RegisterExtensionProtocols();
RegisterMetadataURLRequestHandler();
RegisterBlobURLRequestJobFactory();
RegisterFileSystemURLRequestJobFactory();
*/
{
FilePath plugindata = homedirpath.AppendASCII("plugin_");
if (!file_util::CreateDirectory(plugindata)) {
return false;
}
PluginService::GetInstance()->SetChromePluginDataDir(plugindata);
}
PluginService::GetInstance()->LoadChromePlugins(
g_browser_process->resource_dispatcher_host());
mDefaultRequestContext=mProf->GetRequestContext();
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kRemoteDebuggingPort)) {
std::string debugging_port_str =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kRemoteDebuggingPort);
int64 debugging_port = -1;
bool has_debugging_port = base::StringToInt64(debugging_port_str, &debugging_port);
if (has_debugging_port && debugging_port > 0 && debugging_port < 65535) {
devtools_http_handler_ =
Berkelium::DevToolsHttpProtocolHandler::Start(
"127.0.0.1",
static_cast<int>(debugging_port),
""
);
}
}
return true;
}