本文整理汇总了C++中boost::filesystem::path::string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::string方法的具体用法?C++ path::string怎么用?C++ path::string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestingSetup
TestingSetup() {
fPrintToDebugger = true; // don't want to write to debug.log file
noui_connect();
bitdb.MakeMock();
pathTemp = GetTempPath() / strprintf("test_crunchcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string();
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
InitBlockIndex();
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun);
RegisterWallet(pwalletMain);
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
threadGroup.create_thread(&ThreadScriptCheck);
}
示例2: toEnum
// TEXTURE2D
vgd::Shp< vgd::node::Texture2D > createTexture2D( const vgio::Media & media, const boost::filesystem::path pathFilename, const int index, const aiString aiImagePath,
const aiTextureMapMode mapU, const aiTextureMapMode mapV )
{
// Compute image path
std::string imagePathFilenameStr;
namespace bfs = boost::filesystem;
const bfs::path imagePathFilename = aiImagePath.C_Str();
if ( imagePathFilename.is_absolute() )
{
imagePathFilenameStr = imagePathFilename.string();
}
else // relative path
{
const bfs::path rootPath = pathFilename.parent_path();
imagePathFilenameStr = (rootPath / imagePathFilename).string();
}
// Texture node
using vgd::node::Texture2D;
vgd::Shp< Texture2D > texture = Texture2D::create( imagePathFilename.filename().string(), (int8)index );
// IMAGE
// Gathers the image from the cache.
vgd::Shp< vgd::basic::IImage > image;
image = vgio::ImageCache::load( media, imagePathFilenameStr );
texture->setImage( image );
// Default values
texture->setMipmap( true );
texture->setMinFilter( Texture2D::LINEAR_MIPMAP_LINEAR );
texture->setMagFilter( Texture2D::LINEAR );
// WRAPPING
texture->setWrapS( toEnum(mapU) );
texture->setWrapT( toEnum(mapV) );
// FUNCTION
texture->sethFunction( vgd::node::Texture2D::FUN_MODULATE ); // @todo
return texture;
}
示例3: TestingSetup
TestingSetup() {
fPrintToDebugLog = false; // don't want to write to debug.log file
noui_connect();
#ifdef ENABLE_WALLET
bitcoin_bitdb.MakeMock();
bitcredit_bitdb.MakeMock();
deposit_bitdb.MakeMock();
#endif
pathTemp = GetTempPath() / strprintf("test_credits_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string();
bitcredit_pblocktree = new Credits_CBlockTreeDB(1 << 20, true);
bitcredit_pcoinsdbview = new Credits_CCoinsViewDB(1 << 23, true);
credits_pcoinsTip = new Credits_CCoinsViewCache(*bitcredit_pcoinsdbview);
bitcoin_pblocktree = new Bitcoin_CBlockTreeDB(1 << 20, true);
bitcoin_pcoinsdbview = new Bitcoin_CCoinsViewDB(1 << 23, true);
bitcoin_pcoinsTip = new Bitcoin_CCoinsViewCache(*bitcoin_pcoinsdbview);
Bitcoin_InitBlockIndex();
Credits_InitBlockIndex();
#ifdef ENABLE_WALLET
bool fFirstRun;
bitcoin_pwalletMain = new Bitcoin_CWallet("bitcoin_wallet.dat");
bitcoin_pwalletMain->LoadWallet(fFirstRun);
Bitcoin_RegisterWallet(bitcoin_pwalletMain);
bitcredit_pwalletMain = new Credits_CWallet("credits_wallet.dat", &bitcredit_bitdb);
bitcredit_pwalletMain->LoadWallet(fFirstRun, bitcredit_nAccountingEntryNumber);
Bitcredit_RegisterWallet(bitcredit_pwalletMain);
deposit_pwalletMain = new Credits_CWallet("deposit_wallet.dat", &deposit_bitdb);
deposit_pwalletMain->LoadWallet(fFirstRun, deposit_nAccountingEntryNumber);
Bitcredit_RegisterWallet(deposit_pwalletMain);
#endif
bitcredit_nScriptCheckThreads = 3;
for (int i=0; i < bitcredit_nScriptCheckThreads-1; i++)
threadGroup.create_thread(&Bitcredit_ThreadScriptCheck);
Bitcredit_RegisterNodeSignals(Credits_NetParams()->GetNodeSignals());
}
示例4: loadFile
size_t IOFactory::loadFile( std::list<Chunk> &ret, const boost::filesystem::path &filename, util::istring suffix_override, util::istring dialect )
{
FileFormatList formatReader;
formatReader = getFileFormatList( filename.string(), suffix_override, dialect );
const util::istring with_dialect = dialect.empty() ?
util::istring( "" ) : util::istring( " with dialect \"" ) + dialect + "\"";
if ( formatReader.empty() ) {
if( !boost::filesystem::exists( filename ) ) {
LOG( Runtime, error ) << util::MSubject( filename )
<< " does not exist as file, and no suitable plugin was found to generate data from "
<< ( suffix_override.empty() ? util::istring( "that name" ) : util::istring( "the suffix \"" ) + suffix_override + "\"" );
} else if( suffix_override.empty() ) {
LOG( Runtime, error ) << "No plugin found to read " << filename << with_dialect;
} else {
LOG( Runtime, error ) << "No plugin supporting the requested suffix " << suffix_override << with_dialect << " was found";
}
} else {
BOOST_FOREACH( FileFormatList::const_reference it, formatReader ) {
LOG( ImageIoDebug, info )
<< "plugin to load file" << with_dialect << " " << util::MSubject( filename ) << ": " << it->getName();
try {
int loaded=it->load( ret, filename.native(), dialect, m_feedback );
BOOST_FOREACH( Chunk & ref, ret ) {
if ( ! ref.hasProperty( "source" ) )
ref.setPropertyAs( "source", filename.native() );
}
return loaded;
} catch ( std::runtime_error &e ) {
if( suffix_override.empty() ) {
LOG( Runtime, formatReader.size() > 1 ? warning : error )
<< "Failed to load " << filename << " using " << it->getName() << with_dialect << " ( " << e.what() << " )";
} else {
LOG( Runtime, warning )
<< "The enforced format " << it->getName() << " failed to read " << filename << with_dialect
<< " ( " << e.what() << " ), maybe it just wasn't the right format";
}
}
}
LOG_IF( boost::filesystem::exists( filename ) && formatReader.size() > 1, Runtime, error ) << "No plugin was able to load: " << util::MSubject( filename ) << with_dialect;
}
示例5: load_plugin
void sc_ugen_factory::load_plugin ( boost::filesystem::path const & path )
{
using namespace std;
void * handle = dlopen(path.string().c_str(), RTLD_NOW | RTLD_LOCAL);
if (handle == NULL)
return;
typedef int (*info_function)();
info_function api_version = reinterpret_cast<info_function>(dlsym(handle, "api_version"));
int plugin_api_version = 1; // default
if (api_version)
plugin_api_version = (*api_version)();
if (plugin_api_version != sc_api_version) {
cerr << "API Version Mismatch: " << path << endl;
dlclose(handle);
return;
}
info_function supernova_check = reinterpret_cast<info_function>(dlsym(handle, "server_type"));
if (!supernova_check || (*supernova_check)() == sc_server_scsynth) {
// silently ignore
dlclose(handle);
return;
}
void * load_symbol = dlsym(handle, "load");
if (!load_symbol) {
cerr << "Problem when loading plugin: \"load\" function undefined" << path << endl;
dlclose(handle);
return;
}
open_handles.push_back(handle);
LoadPlugInFunc load_func = reinterpret_cast<LoadPlugInFunc>(load_symbol);
(*load_func)(&sc_interface);
/* don't close the handle */
return;
}
示例6: in_file
std::vector<std::string> psi_util::load_text(fs::path const& file) {
// try to open input stream
std::ifstream in_file(file.c_str());
if (!in_file.good()) {
in_file.close();
throw std::runtime_error("Failed to open text file " + file.string() + ".");
}
// read line by line
std::string line;
std::vector<std::string> contents;
while (in_file.good()) {
getline(in_file, line);
contents.push_back(line + "\n");
}
// close file and return contents
in_file.close();
return contents;
}
示例7: OpenCascStorage
bool OpenCascStorage(int locale)
{
try
{
boost::filesystem::path const storage_dir(boost::filesystem::canonical(input_path) / "Data");
CascStorage = CASC::OpenStorage(storage_dir, WowLocaleToCascLocaleFlags[locale]);
if (!CascStorage)
{
printf("error opening casc storage '%s' locale %s\n", storage_dir.string().c_str(), localeNames[locale]);
return false;
}
return true;
}
catch (boost::filesystem::filesystem_error& error)
{
printf("error opening casc storage : %s\n", error.what());
return false;
}
}
示例8: deleted
void FSSnatSource::deleted(const fs::path& filePath) {
try {
string pathstr = filePath.string();
snat_map_t::iterator it = knownSnats.find(pathstr);
if (it != knownSnats.end()) {
LOG(INFO) << "Removed snat-ip "
<< it->second
<< " at " << filePath;
removeSnat(it->second);
knownSnats.erase(it);
}
} catch (const std::exception& ex) {
LOG(ERROR) << "Could not delete snat for "
<< filePath << ": "
<< ex.what();
} catch (...) {
LOG(ERROR) << "Unknown error while deleting snat information for "
<< filePath;
}
}
示例9: writeVectorToFile
bool writeVectorToFile(boost::filesystem::path path,
const std::vector<T>& vec) {
{
bool binary = std::is_same<T, std::string>::value;
auto flags = std::ios_base::out | std::ios_base::binary;
boost::iostreams::filtering_ostream out;
out.push(boost::iostreams::gzip_compressor(6));
out.push(boost::iostreams::file_sink(path.string(), flags));
size_t num = vec.size();
size_t elemSize = sizeof(typename std::vector<T>::value_type);
// We have to get rid of constness below, but this should be OK
out.write(reinterpret_cast<char*>(const_cast<T*>(vec.data())),
num * elemSize);
out.reset();
}
return true;
}
示例10: Save
bool GameScene::Save(boost::filesystem::path file)
{
m_filepath = file;
using namespace ld3d;
DataStream_File stream;
if(false == stream.OpenStream(file.string().c_str(), false))
{
return false;
}
if(false == m_pCore->GetScene()->Serialize(&stream))
{
return false;
}
stream.Close();
return true;
}
示例11: processFile
ProcessResults processFile(fs::path file, Params& params)
{
ProcessResults result;
Pex::Binary pex;
try
{
Pex::FileReader reader(file.string());
reader.read(pex);
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
return result;
}
if (params.outputAssembly)
{
fs::path asmFile = params.assemblyDir / file.filename().replace_extension(".pas");
try
{
std::ofstream asmStream(asmFile.string());
Decompiler::AsmCoder asmCoder(new Decompiler::StreamWriter(asmStream));
asmCoder.code(pex);
result.push_back(boost::str(boost::format("%1% dissassembled to %2%") % file.string() % asmFile.string()));
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
fs::remove(asmFile);
}
}
fs::path pscFile = params.papyrusDir / file.filename().replace_extension(".psc");
try
{
std::ofstream pscStream(pscFile.string());
Decompiler::PscCoder pscCoder(new Decompiler::StreamWriter(pscStream));
pscCoder.outputAsmComment(params.outputComment).code(pex);
result.push_back(boost::str(boost::format("%1% decompiled to %2%") % file.string() % pscFile.string()));
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
fs::remove(pscFile);
}
return result;
}
示例12:
void
DatasetManager::openFileHelper( boost::filesystem::path aPath, ProgressNotifier::Ptr aProgressNotifier, DatasetID aDatasetId, bool aUseAsCurrent )
{
M4D::Imaging::AImage::Ptr image;
if ( aPath.extension() == ".dcm" || aPath.extension() == ".DCM" ) {
M4D::Dicom::DicomObjSetPtr dicomObjSet = M4D::Dicom::DicomObjSetPtr( new M4D::Dicom::DicomObjSet() );
M4D::Dicom::DcmProvider::LoadSerieThatFileBelongsTo( aPath, aPath.parent_path(), *dicomObjSet, aProgressNotifier );
image = M4D::Dicom::DcmProvider::CreateImageFromDICOM( dicomObjSet );
} else {
image = M4D::Imaging::ImageFactory::LoadDumpedImage( aPath.string() );
}
if (image) {
registerImage( aDatasetId, aPath, image, aUseAsCurrent );
}
if( aProgressNotifier ) {
aProgressNotifier->finished();
}
//mProdconn.PutDataset( image );
}
示例13: run_scripts
void run_scripts(const boost::filesystem::path &p, PyObject *m)
{
std::regex filePattern("^.+\\.py$");
if (!boost::filesystem::is_directory(p))
{
if (std::regex_match(p.leaf().string(), filePattern))
{
std::ifstream input(p.string().c_str());
if (input.is_open())
{
std::string str((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
PyRun_String(str.c_str(), Py_file_input, m, m);
input.close();
}
}
}
}
示例14: makeWriteable
/*!
* Find somewhere safe to write the file.
*
* We work on the assumption that the user's own home directory
* is always writeable. Strictly speaking this is not always
* true but is true enough for most realistic cases.
*
* This function may create empty files as a side-effect. It should
* only be called when we know if will use the resulting file.
*/
static file::path makeWriteable(const file::path& path)
{
if (hbcxx::touch(path.string()))
return file::path{path};
auto home = std::getenv("HOME");
if (nullptr == home)
throw PrePreProcessorError{};
auto filename = file::path{home};
filename /= ".hbcxx";
filename /= file::absolute(path);
(void) file::create_directories(filename.parent_path());
if (hbcxx::touch(filename.string()))
return filename;
throw PrePreProcessorError{};
}
示例15: f
/**
* \brief Create the configuration file, if it does not exists.
* \return true if the file already exists or if it has been created.
*/
bool bf::configuration::create_config_file() const
{
bool result = false;
const boost::filesystem::path path
( path_configuration::get_instance().get_config_directory()
+ s_config_file_name );
if ( !boost::filesystem::exists( path ) )
{
std::ofstream f( path.string().c_str() );
f << s_comment
<< " Configuration file for Bear Factory - Animation editor\n";
}
if ( boost::filesystem::exists( path ) )
result = !boost::filesystem::is_directory( path );
return result;
} // configuration::create_config_file()