本文整理汇总了C++中FilePath::value方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::value方法的具体用法?C++ FilePath::value怎么用?C++ FilePath::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckFileContents
void CheckFileContents(const FilePath& rel_path,
const string& expected_content) {
string actual_contents;
FilePath actual_path = outputDir_.Append(rel_path);
if (!ReadFileToString(actual_path, &actual_contents)) {
FAIL() << "Failed to read expected output file: " << rel_path.value();
}
if (actual_contents != expected_content) {
// When the match fails, display a diff of what's wrong. This greatly
// aids in debugging.
FilePath expected_path;
EXPECT_TRUE(CreateTemporaryFileInDir(tmpDir_, &expected_path));
WriteFile(expected_path, expected_content.c_str(),
expected_content.length());
const size_t buf_len =
strlen(kDiffTemplate) + actual_path.value().length() +
expected_path.value().length() + 1;
unique_ptr<char[]> diff_cmd(new char[buf_len]);
EXPECT_GT(snprintf(diff_cmd.get(), buf_len, kDiffTemplate,
expected_path.value().c_str(),
actual_path.value().c_str()), 0);
system(diff_cmd.get());
FAIL() << "Actual contents of " << rel_path.value()
<< " did not match expected content";
}
}
示例2: EasyDecrypt
errno_t EasyDecrypt(const string& filename, const string& key, string *outFilename)
{
LOGPOS();
FilePath inFilePath(filename);
FileReader reader;
if (reader.Open(inFilePath.value()) != CPT_OK) {
LOGW("Open file %s failed!", inFilePath.value().c_str());
return CPT_ERROR;
}
Decrypt decrypt;
if (decrypt.SetReader(&reader) != CPT_OK) {
LOGW("Decrypt set reader failed!");
return CPT_ERROR;
}
if (decrypt.LoadHeader() != CPT_OK) {
LOGW("Decrypt load header failed!");
return CPT_ERROR;
}
FileHeader *fileHeader = decrypt.DecryptHeader(key.c_str(), key.length());
if (fileHeader == NULL) {
LOGW("LoadHeader error");
return CPT_ERROR;
}
FilePath outFilePath = inFilePath.ReplaceExtension(fileHeader->GetFormat());
*outFilename = outFilePath.value();
FileWriter writer;
if (writer.Open(outFilePath.value()) != CPT_OK) {
LOGW("Create file %s failed!", outFilePath.value().c_str());
return CPT_ERROR;
}
if (decrypt.SetWriter(dynamic_cast<Writer*>(&writer)) != CPT_OK) {
LOGW("Decrypt set writer failed!");
return CPT_ERROR;
}
int err = decrypt.PreDecrypt();
ASSERT(err == CPT_OK);
if (decrypt.DoDecrypt(key.c_str(), key.length())) {
LOGW("Decrypt decrypt file failed!");
return CPT_ERROR;
}
err = decrypt.PostDecrypt();
ASSERT(err == CPT_OK);
return CPT_OK;
}
示例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: fd
Result<Ok, nsresult> MemMapSnapshot::Create(size_t aSize) {
FilePath path;
ScopedCloseFile fd(file_util::CreateAndOpenTemporaryShmemFile(&path));
if (!fd) {
return Err(NS_ERROR_FAILURE);
}
if (HANDLE_EINTR(ftruncate(fileno(fd), aSize)) != 0) {
return Err(NS_ERROR_FAILURE);
}
MOZ_TRY(mMem.init(FILEToFileDescriptor(fd), PR_PROT_READWRITE));
mPath.Assign(path.value().data(), path.value().length());
return Ok();
}
示例5: OpenItemViaShellNoZoneCheck
bool OpenItemViaShellNoZoneCheck(const FilePath& full_path)
{
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.fMask = SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT;
sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = NULL;
sei.lpFile = full_path.value().c_str();
if(::ShellExecuteExW(&sei))
{
return true;
}
LONG_PTR error = reinterpret_cast<LONG_PTR>(sei.hInstApp);
if((error == SE_ERR_NOASSOC))
{
return OpenItemWithExternalApp(full_path.value());
}
return false;
}
示例6: OpenItemViaShell
// Open an item via a shell execute command. Error code checking and casting
// explanation: http://msdn2.microsoft.com/en-us/library/ms647732.aspx
bool OpenItemViaShell(const FilePath& full_path)
{
HINSTANCE h = ::ShellExecuteW(
NULL, NULL, full_path.value().c_str(), NULL,
full_path.DirName().value().c_str(), SW_SHOWNORMAL);
LONG_PTR error = reinterpret_cast<LONG_PTR>(h);
if(error > 32)
{
return true;
}
if((error == SE_ERR_NOASSOC))
{
return OpenItemWithExternalApp(full_path.value());
}
return false;
}
示例7: GetBaseUrl
STDMETHODIMP SilverlightView::GetBaseUrl(BSTR* pbstrUrl)
{
if(pbstrUrl == NULL)
{
return E_POINTER;
}
FilePath path;
PathService::Get(base::DIR_EXE, &path);
std::wstring path_string = path.value();
path_string += L'\\'; // WLW NOTE: hack it. fix later.
*pbstrUrl = SysAllocString(path_string.c_str());
return S_OK;
}
示例8: AmountOfFreeDiskSpace
// static
int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path)
{
ULARGE_INTEGER available, total, free;
if(!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free))
{
return -1;
}
int64 rv = static_cast<int64>(available.QuadPart);
if(rv < 0)
{
rv = kint64max;
}
return rv;
}
示例9: GetSupportedArchitecturesForProcessType
uint32_t GeckoChildProcessHost::GetSupportedArchitecturesForProcessType(GeckoProcessType type)
{
#ifdef MOZ_WIDGET_COCOA
if (type == GeckoProcessType_Plugin) {
// Cache this, it shouldn't ever change.
static uint32_t pluginContainerArchs = 0;
if (pluginContainerArchs == 0) {
FilePath exePath;
GetPathToBinary(exePath);
nsresult rv = GetArchitecturesForBinary(exePath.value().c_str(), &pluginContainerArchs);
NS_ASSERTION(NS_SUCCEEDED(rv) && pluginContainerArchs != 0, "Getting architecture of plugin container failed!");
if (NS_FAILED(rv) || pluginContainerArchs == 0) {
pluginContainerArchs = base::GetCurrentProcessArchitecture();
}
}
return pluginContainerArchs;
}
#endif
return base::GetCurrentProcessArchitecture();
}
示例10: AppendArgPath
void CommandLine::AppendArgPath(const FilePath& path) {
AppendArgNative(path.value());
}
示例11: AppendSwitchPath
void CommandLine::AppendSwitchPath(const std::string& switch_string,
const FilePath& path) {
AppendSwitchNative(switch_string, path.value());
}
示例12: SetProgram
void CommandLine::SetProgram(const FilePath& program) {
//TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
argv_[0] = program.value();
base::trim(argv_[0]);
}
示例13: new_ld_lib_path
//.........这里部分代码省略.........
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
// Preload libmozsandbox.so so that sandbox-related interpositions
// can be defined there instead of in the executable.
// (This could be made conditional on intent to use sandboxing, but
// it's harmless for non-sandboxed processes.)
{
nsAutoCString preload;
// Prepend this, because people can and do preload libpthread.
// (See bug 1222500.)
preload.AssignLiteral("libmozsandbox.so");
if (const char* oldPreload = PR_GetEnv("LD_PRELOAD")) {
// Doesn't matter if oldPreload is ""; extra separators are ignored.
preload.Append(' ');
preload.Append(oldPreload);
}
// Explicitly construct the std::string to make it clear that this
// isn't retaining a pointer to the nsCString's buffer.
newEnvVars["LD_PRELOAD"] = std::string(preload.get());
}
#endif
// 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());
if (pathType == BinaryPathType::Self) {
childArgv.push_back("-contentproc");
}
childArgv.insert(childArgv.end(), aExtraOpts.begin(), aExtraOpts.end());
if (Omnijar::IsInitialized()) {
// Make sure that child processes can find the omnijar
// See XRE_InitCommandLine in nsAppRunner.cpp
nsAutoCString path;
nsCOMPtr<nsIFile> file = Omnijar::GetPath(Omnijar::GRE);
if (file && NS_SUCCEEDED(file->GetNativePath(path))) {
childArgv.push_back("-greomni");
childArgv.push_back(path.get());
}
file = Omnijar::GetPath(Omnijar::APP);
if (file && NS_SUCCEEDED(file->GetNativePath(path))) {
childArgv.push_back("-appomni");
childArgv.push_back(path.get());
}
}
// Add the application directory path (-appdir path)
AddAppDirToCommandLine(childArgv);
childArgv.push_back(pidstring);
#if defined(MOZ_CRASHREPORTER)
# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
int childCrashFd, childCrashRemapFd;
if (!CrashReporter::CreateNotificationPipeForChild(
示例14: parent_recv_port
bool
GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExtraOpts, base::ProcessArchitecture arch)
{
// 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.
#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD)
base::environment_map newEnvVars;
ChildPrivileges privs = mPrivileges;
if (privs == base::PRIVILEGES_DEFAULT) {
privs = kLowRightsSubprocesses ?
base::PRIVILEGES_UNPRIVILEGED : base::PRIVILEGES_INHERIT;
}
// XPCOM may not be initialized in some subprocesses. We don't want
// to initialize XPCOM just for the directory service, especially
// since LD_LIBRARY_PATH is already set correctly in subprocesses
// (meaning that we don't need to set that up in the environment).
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);
# if defined(OS_LINUX) || defined(OS_BSD)
# if defined(MOZ_WIDGET_ANDROID) || defined(OS_BSD)
path += "/lib";
# endif // MOZ_WIDGET_ANDROID
const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH");
nsCString new_ld_lib_path;
if (ld_library_path && *ld_library_path) {
new_ld_lib_path.Assign(path.get());
new_ld_lib_path.AppendLiteral(":");
new_ld_lib_path.Append(ld_library_path);
newEnvVars["LD_LIBRARY_PATH"] = new_ld_lib_path.get();
} else {
newEnvVars["LD_LIBRARY_PATH"] = path.get();
}
# elif OS_MACOSX
newEnvVars["DYLD_LIBRARY_PATH"] = path.get();
// XXX DYLD_INSERT_LIBRARIES should only be set when launching a plugin
// process, and has no effect on other subprocesses (the hooks in
// libplugin_child_interpose.dylib become noops). But currently it
// gets set when launching any kind of subprocess.
//
// Trigger "dyld interposing" for the dylib that contains
// plugin_child_interpose.mm. This allows us to hook OS calls in the
// plugin process (ones that don't work correctly in a background
// process). Don't break any other "dyld interposing" that has already
// been set up by whatever may have launched the browser.
const char* prevInterpose = PR_GetEnv("DYLD_INSERT_LIBRARIES");
nsCString interpose;
if (prevInterpose) {
interpose.Assign(prevInterpose);
interpose.AppendLiteral(":");
}
interpose.Append(path.get());
interpose.AppendLiteral("/libplugin_child_interpose.dylib");
newEnvVars["DYLD_INSERT_LIBRARIES"] = interpose.get();
# endif // OS_LINUX
}
}
}
#endif // OS_LINUX || OS_MACOSX
FilePath exePath;
GetPathToBinary(exePath);
#ifdef MOZ_WIDGET_ANDROID
// The java wrapper unpacks this for us but can't make it executable
chmod(exePath.value().c_str(), 0700);
int cacheCount = 0;
const struct lib_cache_info * cache = getLibraryCache();
nsCString cacheStr;
while (cache &&
cacheCount++ < MAX_LIB_CACHE_ENTRIES &&
//.........这里部分代码省略.........
示例15: parent_recv_port
//.........这里部分代码省略.........
# endif // MOZ_WIDGET_GTK
# elif OS_MACOSX
newEnvVars["DYLD_LIBRARY_PATH"] = path.get();
// XXX DYLD_INSERT_LIBRARIES should only be set when launching a plugin
// process, and has no effect on other subprocesses (the hooks in
// libplugin_child_interpose.dylib become noops). But currently it
// gets set when launching any kind of subprocess.
//
// Trigger "dyld interposing" for the dylib that contains
// plugin_child_interpose.mm. This allows us to hook OS calls in the
// plugin process (ones that don't work correctly in a background
// process). Don't break any other "dyld interposing" that has already
// been set up by whatever may have launched the browser.
const char* prevInterpose = PR_GetEnv("DYLD_INSERT_LIBRARIES");
nsCString interpose;
if (prevInterpose) {
interpose.Assign(prevInterpose);
interpose.Append(':');
}
interpose.Append(path.get());
interpose.AppendLiteral("/libplugin_child_interpose.dylib");
newEnvVars["DYLD_INSERT_LIBRARIES"] = interpose.get();
# endif // OS_LINUX
}
#endif // OS_LINUX || OS_MACOSX
FilePath exePath;
GetPathToBinary(exePath);
#ifdef MOZ_WIDGET_ANDROID
// The java wrapper unpacks this for us but can't make it executable
chmod(exePath.value().c_str(), 0700);
#endif // MOZ_WIDGET_ANDROID
#ifdef ANDROID
// Remap the Android property workspace to a well-known int,
// and update the environment to reflect the new value for the
// child process.
const char *apws = getenv("ANDROID_PROPERTY_WORKSPACE");
if (apws) {
int fd = atoi(apws);
mFileMap.push_back(std::pair<int, int>(fd, kMagicAndroidSystemPropFd));
char buf[32];
char *szptr = strchr(apws, ',');
snprintf(buf, sizeof(buf), "%d%s", kMagicAndroidSystemPropFd, szptr);
newEnvVars["ANDROID_PROPERTY_WORKSPACE"] = buf;
}
#endif // ANDROID
#ifdef MOZ_WIDGET_GONK
if (const char *ldPreloadPath = getenv("LD_PRELOAD")) {
newEnvVars["LD_PRELOAD"] = ldPreloadPath;
}
#endif // MOZ_WIDGET_GONK
// 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