本文整理汇总了C++中fc::path类的典型用法代码示例。如果您正苦于以下问题:C++ path类的具体用法?C++ path怎么用?C++ path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: import
cafs::link cafs::import( const fc::path& p ) {
if( !fc::exists(p) ) {
FC_THROW_MSG( "Path does not exist %s", p.string() );
}
if( fc::is_regular_file( p ) ) {
if( fc::file_size(p) > IMBED_THRESHOLD ) {
auto file_head = import_file(p);
fc::vector<char> data(MAX_CHUNK_SIZE);
fc::datastream<char*> ds(data.data()+1, data.size()-1);
fc::raw::pack( ds, file_head );
data[0] = cafs::file_header_type;
//fc::datastream<const char*> ds2(data.data()+1, data.size()-1);
//file_header tmp;
//fc::raw::unpack( ds2, tmp );
//slog( "test unpack %s", fc::json::to_string( tmp ).c_str() );
data.resize( ds.tellp() );
//slog( "pre randomized... '%s'", fc::to_hex( data.data(), 16 ).c_str() );
size_t seed = randomize(data, *((uint64_t*)fc::sha1::hash(data.data(),data.size()).data()) );
auto chunk_head = slice_chunk( data );
//slog( "slice chunk %s", fc::json::to_string( chunk_head ).c_str() );
store_chunk( chunk_head, data );
return link( chunk_head.calculate_id(), seed );
} else { // no header, just raw data from the file stored in the chunk
fc::vector<char> data( fc::file_size(p)+1 );
data[0] = file_data_type;
fc::ifstream ifile( p.string(), fc::ifstream::binary );
ifile.read( data.data()+1, data.size()-1 );
size_t seed = randomize(data, *((uint64_t*)fc::sha1::hash(data.data(),data.size()).data()) );
auto chunk_head = slice_chunk( data );
store_chunk( chunk_head, data );
return link( chunk_head.calculate_id(), seed );
}
}
else if( fc::is_directory(p) ) {
auto dir = import_directory(p);
fc::vector<char> data(MAX_CHUNK_SIZE);
fc::datastream<char*> ds(data.data()+1, data.size()-1);
fc::raw::pack( ds, dir );
data[0] = directory_type;
data.resize( ds.tellp()+1 );
size_t seed = randomize(data, *((uint64_t*)fc::sha1::hash(data.data(),data.size()).data()) );
auto chunk_head = slice_chunk( data );
link l( chunk_head.calculate_id(), seed );
store_chunk( chunk_head, data );
return l;
}
FC_THROW_MSG( "Unsupported file type while importing '%s'", p.string() );
return cafs::link();
}
开发者ID:Zhang-Yi,项目名称:tornet,代码行数:56,代码来源:cafs.cpp
示例2:
fc::string detail::process_impl::windows_shell_escape_command(const fc::path& exe, const vector<string>& args) {
fc::stringstream command_line;
command_line << windows_shell_escape(exe.string());
for (unsigned i = 0; i < args.size(); ++i)
command_line << " " << windows_shell_escape(args[i]);
return command_line.str();
}
开发者ID:techsharesteam,项目名称:techshares,代码行数:7,代码来源:process.cpp
示例3: import_bitcoin_wallet
std::vector<fc::ecc::private_key> import_bitcoin_wallet( const fc::path& wallet_dat, const std::string& passphrase )
{ try {
wallet_db db( wallet_dat.to_native_ansi_path().c_str() );
return collect_keys( db, passphrase );
} FC_RETHROW_EXCEPTIONS( warn, "" ) }
开发者ID:BrownBear2,项目名称:BitShares,代码行数:7,代码来源:bitcoin_wallet.cpp
示例4: load_genesis
signed_transaction load_genesis( const fc::path& csv, uint64_t& total_coins )
{
total_coins = 0;
signed_transaction coinbase;
coinbase.version = 0;
// coinbase.valid_after = 0;
// coinbase.valid_blocks = 0;
std::ifstream in(csv.generic_string().c_str(), std::ios::binary);
std::string line;
std::getline( in, line );
while( in.good() )
{
std::stringstream ss(line);
std::string addr;
uint64_t amnt;
ss >> addr >> amnt;
total_coins += amnt;
coinbase.outputs.push_back(
trx_output( claim_by_pts_output( bts::pts_address(addr) ), amnt, asset::bts) );
std::getline( in, line );
}
return coinbase;
}
开发者ID:1manStartup,项目名称:BitShares,代码行数:25,代码来源:server.cpp
示例5: compile_json_to_source
void compile_json_to_source(
const fc::path& source_file_name,
const fc::path& prologue_file_name,
const fc::path& json_file_name,
const fc::path& epilogue_file_name
)
{
fc::mutable_variant_object template_context;
template_context[ "source_file_name"] = source_file_name.string();
template_context["prologue_file_name"] = prologue_file_name.string();
template_context[ "json_file_name"] = json_file_name.string();
template_context["epilogue_file_name"] = epilogue_file_name.string();
std::ofstream source_file(source_file_name.string());
if (prologue_file_name.string() != "")
{
std::ifstream prologue_file(prologue_file_name.string());
std::stringstream ss_prologue_file;
ss_prologue_file << prologue_file.rdbuf();
source_file << format_string(ss_prologue_file.str(), template_context);
}
std::ifstream json_file(json_file_name.string());
std::string line;
bool first = true;
while (std::getline(json_file, line))
{
if (first)
first = false;
else
source_file << ",\n";
source_file << " " << bts::utilities::escape_string_for_c_source_code(line);
}
if (epilogue_file_name.string() != "")
{
std::ifstream epilogue_file(epilogue_file_name.string());
std::stringstream ss_epilogue_file;
ss_epilogue_file << epilogue_file.rdbuf();
source_file << format_string(ss_epilogue_file.str(), template_context);
}
return;
}
开发者ID:AlexChien,项目名称:bitshares,代码行数:47,代码来源:bts_json_to_cpp.cpp
示例6: import_electrum_wallet
std::vector<fc::ecc::private_key> import_electrum_wallet( const fc::path& wallet_dat, const std::string& passphrase )
{ try {
std::vector<fc::ecc::private_key> keys;
electrumwallet wallet( wallet_dat.to_native_ansi_path());
if( !wallet.ok() ) FC_THROW_EXCEPTION( fc::invalid_arg_exception, "invalid electrum wallet");
wallet.derivekeys( passphrase );
return wallet.keys();
} FC_RETHROW_EXCEPTIONS( warn, "" ) }
开发者ID:371061198,项目名称:bitshares_toolkit,代码行数:8,代码来源:electrum.cpp
示例7: create_genesis_block
void create_genesis_block(fc::path genesis_json_file)
{
vector<fc::ecc::private_key> delegate_private_keys;
genesis_block_config config;
config.precision = BTS_BLOCKCHAIN_PRECISION;
config.timestamp = bts::blockchain::now();
config.base_symbol = BTS_BLOCKCHAIN_SYMBOL;
config.base_name = BTS_BLOCKCHAIN_NAME;
config.base_description = BTS_BLOCKCHAIN_DESCRIPTION;
config.supply = BTS_BLOCKCHAIN_INITIAL_SHARES;
// set our fake random number generator to generate deterministic keys
set_random_seed_for_testing(fc::sha512());
std::ofstream key_stream( genesis_json_file.string() + ".keypairs" );
//create a script for importing the delegate keys
std::ofstream delegate_key_import_stream(genesis_json_file.string() + ".log");
delegate_key_import_stream << CLI_PROMPT_SUFFIX " enable_output false" << std::endl;
std::cout << "*** creating delegate public/private key pairs ***" << std::endl;
for( uint32_t i = 0; i < BTS_BLOCKCHAIN_NUM_DELEGATES; ++i )
{
name_config delegate_account;
delegate_account.name = "delegate" + fc::to_string(i);
fc::ecc::private_key delegate_private_key = fc::ecc::private_key::generate();
delegate_private_keys.push_back( delegate_private_key );
auto delegate_public_key =delegate_private_key.get_public_key();
delegate_account.owner = delegate_public_key;
delegate_account.is_delegate = true;
config.names.push_back(delegate_account);
config.balances.push_back( std::make_pair( pts_address(fc::ecc::public_key_data(delegate_account.owner)), BTS_BLOCKCHAIN_INITIAL_SHARES/BTS_BLOCKCHAIN_NUM_DELEGATES) );
//output public/private key pair for each delegate to a file
string wif_key = bts::utilities::key_to_wif( delegate_private_key );
key_stream << std::string(delegate_account.owner) << " " << wif_key << std::endl;
//add command to import the delegate keys into a client
delegate_key_import_stream << CLI_PROMPT_SUFFIX " wallet_import_private_key " << wif_key << " " << delegate_account.name << " false" << std::endl;
}
delegate_key_import_stream << CLI_PROMPT_SUFFIX " enable_output true" << std::endl;
fc::json::save_to_file( config, genesis_json_file);
}
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:43,代码来源:wallet_tests.cpp
示例8: options
bts_xt_client_test_config()
{
// parse command-line options
boost::program_options::options_description option_config("Allowed options");
option_config.add_options()("bts-client-exe", boost::program_options::value<std::string>(), "full path to the executable to test")
("bts-server-exe", boost::program_options::value<std::string>(), "full path to the server executable for testing client-server mode")
("extra-help", "display this help message");
boost::program_options::variables_map option_variables;
try
{
boost::program_options::store(boost::program_options::command_line_parser(boost::unit_test::framework::master_test_suite().argc,
boost::unit_test::framework::master_test_suite().argv).
options(option_config).run(), option_variables);
boost::program_options::notify(option_variables);
}
catch (boost::program_options::error&)
{
std::cerr << "Error parsing command-line options\n\n";
std::cerr << option_config << "\n";
exit(1);
}
if (option_variables.count("extra-help"))
{
std::cout << option_config << "\n";
exit(0);
}
if (option_variables.count("bts-client-exe"))
bts_client_exe = option_variables["bts-client-exe"].as<std::string>().c_str();
if (option_variables.count("bts-server-exe"))
bts_server_exe = option_variables["bts-server-exe"].as<std::string>().c_str();
std::cout << "Testing " << bts_client_exe.string() << "\n";
std::cout << "Using config directory " << config_directory.string() << "\n";
fc::create_directories(config_directory);
boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_messages);
}
开发者ID:bitsharesinterest,项目名称:bitshares_toolkit,代码行数:42,代码来源:bts_xt_client_tests.cpp
示例9: open
void profile::open( const fc::path& profile_dir, const std::string& password )
{ try {
ilog("opening profile: ${profile_dir}",("profile_dir",profile_dir));
my->_profile_name = profile_dir.filename().generic_wstring();
fc::create_directories( profile_dir );
fc::create_directories( profile_dir / "addressbook" );
fc::create_directories( profile_dir / "idents" );
fc::create_directories( profile_dir / "mail" );
fc::create_directories( profile_dir / "mail" / "inbox" );
fc::create_directories( profile_dir / "mail" / "draft" );
fc::create_directories( profile_dir / "mail" / "pending" );
fc::create_directories( profile_dir / "mail" / "sent" );
fc::create_directories( profile_dir / "chat" );
fc::create_directories( profile_dir / "request" );
fc::create_directories( profile_dir / "authorization" );
ilog("loading master key file:" KEYHOTEE_MASTER_KEY_FILE);
auto profile_cfg_key = fc::sha512::hash( password.c_str(), password.size() );
std::vector<char> stretched_seed_data;
try {
stretched_seed_data = fc::aes_load( profile_dir / KEYHOTEE_MASTER_KEY_FILE, profile_cfg_key );
}
catch (fc::exception& /* e */)
{ //try to open legacy name for key file
wlog("Could not open " KEYHOTEE_MASTER_KEY_FILE ", trying to open legacy key file (.strecthed_seed).");
stretched_seed_data = fc::aes_load( profile_dir / ".stretched_seed", profile_cfg_key );
}
ilog("opening profile databases");
my->_keychain.set_seed( fc::raw::unpack<fc::sha512>(stretched_seed_data) );
my->_addressbook->open( profile_dir / "addressbook", profile_cfg_key );
my->_idents.open( profile_dir / "idents" );
my->_inbox_db->open( profile_dir / "mail" / "inbox", profile_cfg_key );
my->_draft_db->open( profile_dir / "mail" / "draft", profile_cfg_key );
my->_pending_db->open( profile_dir / "mail" / "pending", profile_cfg_key );
my->_sent_db->open( profile_dir / "mail" / "sent", profile_cfg_key );
my->_chat_db->open( profile_dir / "chat", profile_cfg_key );
my->_request_db->open( profile_dir / "request", profile_cfg_key );
my->_auth_db->open( profile_dir / "authorization", profile_cfg_key );
my->_last_sync_time.open( profile_dir / "mail" / "last_recv", true );
if( *my->_last_sync_time == fc::time_point())
{
*my->_last_sync_time = fc::time_point::now() - fc::days(5);
ilog("set last_sync_time to ${t}",("t",*my->_last_sync_time));
}
else
ilog("loaded last_sync_time = ${t}",("t",*my->_last_sync_time));
ilog("finished opening profile");
} FC_RETHROW_EXCEPTIONS( warn, "", ("profile_dir",profile_dir) ) }
开发者ID:drltc,项目名称:BitShares,代码行数:50,代码来源:profile.cpp
示例10: open
void open( const fc::path& dir, bool create = true, size_t cache_size = 0 )
{ try {
FC_ASSERT( !is_open(), "Database is already open!" );
ldb::Options opts;
opts.comparator = &_comparer;
opts.create_if_missing = create;
opts.max_open_files = 64;
opts.compression = leveldb::kNoCompression;
if( cache_size > 0 )
{
opts.write_buffer_size = cache_size / 4; // up to two write buffers may be held in memory simultaneously
_cache.reset( leveldb::NewLRUCache( cache_size / 2 ) );
opts.block_cache = _cache.get();
}
if( ldb::kMajorVersion > 1 || ( leveldb::kMajorVersion == 1 && leveldb::kMinorVersion >= 16 ) )
{
// LevelDB versions before 1.16 consider short writes to be corruption. Only trigger error
// on corruption in later versions.
opts.paranoid_checks = true;
}
_read_options.verify_checksums = true;
_iter_options.verify_checksums = true;
_iter_options.fill_cache = false;
_sync_options.sync = true;
// Given path must exist to succeed toNativeAnsiPath
fc::create_directories( dir );
std::string ldbPath = dir.to_native_ansi_path();
ldb::DB* ndb = nullptr;
const auto ntrxstat = ldb::DB::Open( opts, ldbPath.c_str(), &ndb );
if( !ntrxstat.ok() )
{
elog( "Failure opening database: ${db}\nStatus: ${msg}", ("db",dir)("msg",ntrxstat.ToString()) );
FC_THROW_EXCEPTION( level_pod_map_open_failure, "Failure opening database: ${db}\nStatus: ${msg}",
("db",dir)("msg",ntrxstat.ToString()) );
}
_db.reset( ndb );
try_upgrade_db( dir, ndb, fc::get_typename<Value>::name(), sizeof( Value ) );
} FC_CAPTURE_AND_RETHROW( (dir)(create)(cache_size) ) }
开发者ID:ElleryHao,项目名称:Goopal,代码行数:45,代码来源:LevelPodMap.hpp
示例11: close
void peer_database_impl::close() {
std::vector<potential_peer_record> peer_records;
peer_records.reserve(_potential_peer_set.size());
std::copy(_potential_peer_set.begin(), _potential_peer_set.end(), std::back_inserter(peer_records));
try {
fc::path peer_database_filename_dir = _peer_database_filename.parent_path();
if (!fc::exists(peer_database_filename_dir)) {
fc::create_directories(peer_database_filename_dir);
}
fc::json::save_to_file(peer_records, _peer_database_filename);
}
catch (const fc::exception &e) {
elog("error saving peer database to file ${peer_database_filename}",
("peer_database_filename", _peer_database_filename));
}
_potential_peer_set.clear();
}
开发者ID:Rsteem,项目名称:steem,代码行数:18,代码来源:peer_database.cpp
示例12: open
void open( const fc::path& dir, bool create = true, size_t cache_size = 0 )
{ try {
ldb::Options opts;
opts.comparator = &_comparer;
opts.create_if_missing = create;
if (cache_size) {
_cache.reset(leveldb::NewLRUCache(cache_size));
opts.block_cache = _cache.get();
}
/*
if( ldb::kMajorVersion > 1 || ( leveldb::kMajorVersion == 1 && leveldb::kMinorVersion >= 16 ) )
{
// LevelDB versions before 1.16 consider short writes to be corruption. Only trigger error
// on corruption in later versions.
opts.paranoid_checks = true;
}
opts.max_open_files = 64;
_read_options.verify_checksums = true;
_iter_options.verify_checksums = true;
_iter_options.fill_cache = false;
_sync_options.sync = true;
*/
/// \warning Given path must exist to succeed toNativeAnsiPath
fc::create_directories(dir);
std::string ldbPath = dir.to_native_ansi_path();
ldb::DB* ndb = nullptr;
auto ntrxstat = ldb::DB::Open( opts, ldbPath.c_str(), &ndb );
if( !ntrxstat.ok() )
{
FC_THROW_EXCEPTION( db_in_use_exception, "Unable to open database ${db}\n\t${msg}",
("db",dir)
("msg",ntrxstat.ToString())
);
}
_db.reset(ndb);
try_upgrade_db( dir,ndb, fc::get_typename<Value>::name(),sizeof(Value) );
} FC_RETHROW_EXCEPTIONS( warn, "" ) }
开发者ID:andrewisplinghoff,项目名称:bitsharesx,代码行数:42,代码来源:level_map.hpp
示例13: open
void mmap_struct_base::open( const fc::path& file, size_t s, bool create )
{
if( !fc::exists( file ) || fc::file_size(file) != s )
{
fc::ofstream out( file );
char buffer[1024];
memset( buffer, 0, sizeof(buffer) );
size_t bytes_left = s;
while( bytes_left > 0 )
{
size_t to_write = std::min<size_t>(bytes_left, sizeof(buffer) );
out.write( buffer, to_write );
bytes_left -= to_write;
}
}
std::string filePath = file.to_native_ansi_path();
_file_mapping.reset( new fc::file_mapping( filePath.c_str(), fc::read_write ) );
_mapped_region.reset( new fc::mapped_region( *_file_mapping, fc::read_write, 0, s ) );
}
开发者ID:techsharesteam,项目名称:techshares,代码行数:22,代码来源:mmap_struct.cpp
示例14: open
void open( const fc::path& dir, bool create = true )
{
ldb::Options opts;
opts.create_if_missing = create;
opts.comparator = & _comparer;
/// \waring Given path must exist to succeed toNativeAnsiPath
fc::create_directories(dir);
std::string ldbPath = dir.to_native_ansi_path();
ldb::DB* ndb = nullptr;
auto ntrxstat = ldb::DB::Open( opts, ldbPath.c_str(), &ndb );
if( !ntrxstat.ok() )
{
FC_THROW_EXCEPTION( db_in_use_exception, "Unable to open database ${db}\n\t${msg}",
("db",dir)
("msg",ntrxstat.ToString())
);
}
_db.reset(ndb);
UpgradeDbIfNecessary(dir,ndb, fc::get_typename<Value>::name(),sizeof(Value));
}
开发者ID:BrownBear2,项目名称:BitShares,代码行数:23,代码来源:level_map.hpp
示例15: import_file
/**
* Imports the file chunks into the database, but does not
* import the file_header itself as a chunk, as it may be
* imbedded within another chunk.
*
* @pre is_regular_file(p)
*/
cafs::file_header cafs::import_file( const fc::path& p ) {
file_header head;
head.file_size = fc::file_size(p);
fc::vector<char> chunk( MAX_CHUNK_SIZE );
// divide file up into chunks and slices
fc::ifstream in( p.string(), fc::ifstream::binary );
uint32_t r = 0;
while( r < head.file_size ) {
size_t some = fc::min( size_t(chunk.size()), size_t(head.file_size-r) );
in.read( chunk.data(), some );
size_t seed = randomize(chunk, *((uint64_t*)fc::sha1::hash(chunk.data(),chunk.size()).data()) );
chunk.resize(some);
auto chunk_head = slice_chunk(chunk);
auto chunk_id = store_chunk( chunk_head, chunk );
head.add_chunk( chunk_id, seed, chunk_head );
r += some;
}
return head;
}
开发者ID:Zhang-Yi,项目名称:tornet,代码行数:30,代码来源:cafs.cpp
示例16: run_regression_test
void run_regression_test(fc::path test_dir, bool with_network)
{
set_random_seed_for_testing(fc::sha512());
// open testconfig file
// for each line in testconfig file
// add a verify_file object that knows the name of the input command file and the generated log file
// start a process with that command line
// wait for all processes to shutdown
// for each verify_file object,
// compare generated log files in datadirs to golden reference file (i.e. input command files)
// caller of this routine should have made sure we are already in bitshares_toolkit/test dir.
// so we pop dirs to create regression_tests_results as sibling to bitshares_toolkit source directory
// (because we don't want the test results to be inadvertantly added to git repo).
fc::path original_working_directory = boost::filesystem::current_path();
fc::path regression_test_output_directory = original_working_directory.parent_path().parent_path();
regression_test_output_directory /= "regression_tests_output";
// Create an expected output file in the test subdir for the test output.
fc::path test_output_dir = regression_test_output_directory / test_dir;
boost::filesystem::create_directories(test_output_dir);
fc::path expected_output_file = test_output_dir / "expected_output.log";
std::ofstream expected_output_stream(expected_output_file.string());
try
{
std::cout << "*** Executing " << test_dir.string() << std::endl;
boost::filesystem::current_path(test_dir.string());
//create a small genesis block to reduce test startup time
//fc::temp_directory temp_dir;
//fc::path genesis_json_file = temp_dir.path() / "genesis.json";
//create_genesis_block(genesis_json_file);
//DLN: now we just used the genesis file already committed to repo, update it
// using "-t make_genesis_block" if desired.
fc::path genesis_json_file = "../../test_genesis.json";
//open test configuration file (contains one line per client to create)
fc::path test_config_file_name = "test.config";
std::ifstream test_config_file(test_config_file_name.string());
//create one client per line and run each client's input commands
auto sim_network = std::make_shared<bts::net::simulated_network>();
vector<test_file> tests;
string line = " --min-delegate-connection-count=0 ";
fc::future<void> client_done;
while (std::getline(test_config_file,line))
{
//append genesis_file to load to command-line for now (later should be pre-created in test dir I think)
line += " --genesis-config " + genesis_json_file.string();
//if no data-dir specified, put in ../bitshares_toolkit/regression_tests/${test dir}/${client_name}
string client_name = line.substr(0, line.find(' '));
size_t data_dir_position = line.find("--data-dir");
if (data_dir_position == string::npos)
{
fc::path default_data_dir = regression_test_output_directory / test_dir / client_name;
line += " --data-dir=" + default_data_dir.string();
fc::remove_all(default_data_dir);
}
//parse line into argc/argv format for boost program_options
int argc = 0;
char** argv = nullptr;
#ifndef WIN32 // then UNIX
//use wordexp to get argv/arc
wordexp_t wordexp_result;
wordexp(line.c_str(), &wordexp_result, 0);
auto option_variables = parse_option_variables(wordexp_result.we_wordc, wordexp_result.we_wordv);
argv = wordexp_result.we_wordv;
argc = wordexp_result.we_wordc;
#else
//use ExpandEnvironmentStrings and CommandLineToArgv to get argv/arc
char expanded_line[40000];
ExpandEnvironmentStrings(line.c_str(),expanded_line,sizeof(expanded_line));
argv = CommandLineToArgvA(expanded_line,&argc);
auto option_variables = bts::client::parse_option_variables(argc, argv);
#endif
//extract input command files from cmdline options and concatenate into
//one expected output file so that we can compare against output log
std::vector<string> input_logs = option_variables["input-log"].as<std::vector<string>>();
for (string input_log : input_logs)
{
std::ifstream input_stream(input_log);
expected_output_stream << input_stream.rdbuf();
}
expected_output_stream.close();
//run client with cmdline options
if (with_network)
{
FC_ASSERT(false, "Not implemented yet!")
}
else
{
//.........这里部分代码省略.........
开发者ID:HackFisher,项目名称:bitshares_snapshot,代码行数:101,代码来源:wallet_tests.cpp
示例17: pack
inline void pack( Stream& s, const fc::path& tp )
{
fc::raw::pack( s, tp.generic_string() );
}
开发者ID:dbarobin,项目名称:steem,代码行数:4,代码来源:raw.hpp
示例18: open
void ifstream::open( const fc::path& file, int m ) {
my->ifs.open( file.string().c_str(), std::ios::binary );
}
开发者ID:BrownBear2,项目名称:fc,代码行数:3,代码来源:fstream.cpp
示例19: load_logging_config_from_ini_file
fc::optional<fc::logging_config> load_logging_config_from_ini_file(const fc::path& config_ini_filename)
{
try
{
fc::logging_config logging_config;
bool found_logging_config = false;
boost::property_tree::ptree config_ini_tree;
boost::property_tree::ini_parser::read_ini(config_ini_filename.preferred_string().c_str(), config_ini_tree);
for (const auto& section : config_ini_tree)
{
const std::string& section_name = section.first;
const boost::property_tree::ptree& section_tree = section.second;
const std::string console_appender_section_prefix = "log.console_appender.";
const std::string file_appender_section_prefix = "log.file_appender.";
const std::string logger_section_prefix = "logger.";
if (boost::starts_with(section_name, console_appender_section_prefix))
{
std::string console_appender_name = section_name.substr(console_appender_section_prefix.length());
std::string stream_name = section_tree.get<std::string>("stream");
// construct a default console appender config here
// stdout/stderr will be taken from ini file, everything else hard-coded here
fc::console_appender::config console_appender_config;
console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::debug,
fc::console_appender::color::green));
console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::warn,
fc::console_appender::color::brown));
console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::error,
fc::console_appender::color::cyan));
console_appender_config.stream = fc::variant(stream_name).as<fc::console_appender::stream::type>();
logging_config.appenders.push_back(fc::appender_config(console_appender_name, "console", fc::variant(console_appender_config)));
found_logging_config = true;
}
else if (boost::starts_with(section_name, file_appender_section_prefix))
{
std::string file_appender_name = section_name.substr(file_appender_section_prefix.length());
fc::path file_name = section_tree.get<std::string>("filename");
if (file_name.is_relative())
file_name = fc::absolute(config_ini_filename).parent_path() / file_name;
// construct a default file appender config here
// filename will be taken from ini file, everything else hard-coded here
fc::file_appender::config file_appender_config;
file_appender_config.filename = file_name;
file_appender_config.flush = true;
file_appender_config.rotate = true;
file_appender_config.rotation_interval = fc::hours(1);
file_appender_config.rotation_limit = fc::days(1);
logging_config.appenders.push_back(fc::appender_config(file_appender_name, "file", fc::variant(file_appender_config)));
found_logging_config = true;
}
else if (boost::starts_with(section_name, logger_section_prefix))
{
std::string logger_name = section_name.substr(logger_section_prefix.length());
std::string level_string = section_tree.get<std::string>("level");
std::string appenders_string = section_tree.get<std::string>("appenders");
fc::logger_config logger_config(logger_name);
logger_config.level = fc::variant(level_string).as<fc::log_level>();
boost::split(logger_config.appenders, appenders_string,
boost::is_any_of(" ,"),
boost::token_compress_on);
logging_config.loggers.push_back(logger_config);
found_logging_config = true;
}
}
if (found_logging_config)
return logging_config;
else
return fc::optional<fc::logging_config>();
}
FC_RETHROW_EXCEPTIONS(warn, "")
}
开发者ID:iamsmooth,项目名称:steem,代码行数:79,代码来源:main.cpp
示例20: import_bitcoin_wallet
bool rpc_client_impl::import_bitcoin_wallet(const fc::path& wallet_filename, const std::string& password)
{
return _json_connection->call<bool>("import_bitcoin_wallet", wallet_filename.string(), password);
}
开发者ID:jcalfee,项目名称:bitshares_toolkit,代码行数:4,代码来源:rpc_client.cpp
注:本文中的fc::path类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论