当前位置: 首页>>代码示例>>C++>>正文


C++ FilePath::value方法代码示例

本文整理汇总了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";
    }
  }
开发者ID:cuteboot,项目名称:aidl-upstream,代码行数:27,代码来源:end_to_end_tests.cpp

示例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;
}
开发者ID:huangaming,项目名称:libcryptocpp,代码行数:54,代码来源:Crypto.cpp

示例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);
}
开发者ID:cnxsoft,项目名称:xibo4arm,代码行数:7,代码来源:Root.cpp

示例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();
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:16,代码来源:MemMapSnapshot.cpp

示例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;
 }
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:18,代码来源:shell.cpp

示例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;
        }
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:21,代码来源:shell.cpp

示例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;
 }
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:13,代码来源:silverlight_view.cpp

示例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;
 }
开发者ID:kanego,项目名称:CoreProject,代码行数:15,代码来源:sys_info.cpp

示例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();
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:21,代码来源:GeckoChildProcessHost.cpp

示例10: AppendArgPath

	void CommandLine::AppendArgPath(const FilePath& path) {
		AppendArgNative(path.value());
	}
开发者ID:tantaishan,项目名称:MyEcho,代码行数:3,代码来源:command_line.cpp

示例11: AppendSwitchPath

	void CommandLine::AppendSwitchPath(const std::string& switch_string,
		const FilePath& path) {
			AppendSwitchNative(switch_string, path.value());
	}
开发者ID:tantaishan,项目名称:MyEcho,代码行数:4,代码来源:command_line.cpp

示例12: SetProgram

	void CommandLine::SetProgram(const FilePath& program) {
		//TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
		argv_[0] = program.value();
		base::trim(argv_[0]);
	}
开发者ID:tantaishan,项目名称:MyEcho,代码行数:5,代码来源:command_line.cpp

示例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(
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:67,代码来源:GeckoChildProcessHost.cpp

示例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 &&
//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:101,代码来源:GeckoChildProcessHost.cpp

示例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
开发者ID:qiuyang001,项目名称:Spidermonkey,代码行数:67,代码来源:GeckoChildProcessHost.cpp


注:本文中的FilePath::value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。