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


C++ path::parent_path方法代码示例

本文整理汇总了C++中fc::path::parent_path方法的典型用法代码示例。如果您正苦于以下问题:C++ path::parent_path方法的具体用法?C++ path::parent_path怎么用?C++ path::parent_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fc::path的用法示例。


在下文中一共展示了path::parent_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: export_link

void cafs::export_link( const cafs::link& l, const fc::path& d ) {
 try {
    if( !fc::exists( d.parent_path() ) ) { 
      slog( "create '%s'", d.generic_string().c_str() );
      fc::create_directories(d.parent_path()); 
    }
    fc::vector<char> ch = get_chunk( l.id );
    derandomize( l.seed, ch  );
    //  slog( "derandomized... '%s'", fc::to_hex( ch.data(), 16 ).c_str() );
    if( ch.size() == 0 ) {
      FC_THROW_MSG( "Empty Chunk!" );
    }
    switch( ch[0] ) {
      case file_data_type: {
        slog( "file data..." );
    //    slog( "post randomized... '%s'", fc::to_hex( ch.data(), ch.size() ).c_str() );
        fc::ofstream ofile( d, fc::ofstream::binary );
        ofile.write( ch.data()+1, ch.size()-1 );
        break;
      }
      case directory_type: {
        slog( "directory data..." );
        fc::datastream<const char*> ds(ch.data()+1, ch.size()-1);
        directory d;
        fc::raw::unpack( ds, d );
        slog( "%s", fc::json::to_string( d ).c_str() );
        for( auto itr = d.entries.begin(); itr != d.entries.end(); ++itr ) {
          slog( "entry: %s", itr->name.c_str() );
          /*
          fc::vector<char> fdat = get_file( itr->ref );
          switch( itr->ref.type ) {
            case file_data_type: {
              break;
            }
            case directory_type: {
              slog( "%s", fc::json::to_string( fc::raw::unpack<directory>(fdat) ).c_str() );
              break;
            }
            case file_header_type: {
              slog( "%s", fc::json::to_string( fc::raw::unpack<file_header>(fdat) ).c_str() );
              break;
            }
            default:
              wlog( "Unknown Type %d", int(itr->ref.type) );
          }
          */
        }
  
        break;
      }
      case file_header_type: {
        slog( "file header..." );
        fc::datastream<const char*> ds(ch.data()+1, ch.size()-1);
        slog( "data %s", fc::to_hex( ch.data(), 16 ).c_str() );
        file_header fh;
        fc::raw::unpack( ds, fh);
        slog( "%s", fc::json::to_string( fh ).c_str() );
  
        fc::ofstream ofile( d, fc::ofstream::binary );
        for( auto i = fh.chunks.begin(); i != fh.chunks.end(); ++i ) {
          fc::vector<char> c = get_chunk( i->hash );
          derandomize( i->seed, c );
          ofile.write( c.data(), c.size() );
        }
        break;
      }
      default:
        FC_THROW_MSG( "Unknown File Type %s", int(ch[0]) );
    }
 } catch ( fc::error_report& e ) {
   throw FC_REPORT_PUSH( e, "Unable to export link ${link} to ${path}", fc::value().set("link", fc::string(l)).set("path", d.generic_string() ) );
 }
}
开发者ID:Zhang-Yi,项目名称:tornet,代码行数:73,代码来源:cafs.cpp


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