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


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

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


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

示例1: open

   void database::open( const bfs::path& dir, uint32_t flags, size_t shared_file_size, const boost::any& database_cfg )
   {
      assert( dir.is_absolute() );
      bfs::create_directories( dir );
      if( _data_dir != dir ) close();

      _data_dir = dir;
      _database_cfg = database_cfg;

#ifndef ENABLE_MIRA
      auto abs_path = bfs::absolute( dir / "shared_memory.bin" );

      if( bfs::exists( abs_path ) )
      {
         _file_size = bfs::file_size( abs_path );
         if( shared_file_size > _file_size )
         {
            if( !bip::managed_mapped_file::grow( abs_path.generic_string().c_str(), shared_file_size - _file_size ) )
               BOOST_THROW_EXCEPTION( std::runtime_error( "could not grow database file to requested size." ) );

            _file_size = shared_file_size;
         }

         _segment.reset( new bip::managed_mapped_file( bip::open_only,
                                                       abs_path.generic_string().c_str()
                                                       ) );

         auto env = _segment->find< environment_check >( "environment" );
         if( !env.first || !( *env.first == environment_check()) ) {
            BOOST_THROW_EXCEPTION( std::runtime_error( "database created by a different compiler, build, or operating system" ) );
         }
      } else {
         _file_size = shared_file_size;
         _segment.reset( new bip::managed_mapped_file( bip::create_only,
                                                       abs_path.generic_string().c_str(), shared_file_size
                                                       ) );
         _segment->find_or_construct< environment_check >( "environment" )();
      }

      _flock = bip::file_lock( abs_path.generic_string().c_str() );
      if( !_flock.try_lock() )
         BOOST_THROW_EXCEPTION( std::runtime_error( "could not gain write access to the shared memory file" ) );
#else
      for( auto& item : _index_list )
      {
         item->open( _data_dir, _database_cfg );
      }
#endif
      _is_open = true;
   }
开发者ID:dbarobin,项目名称:steem,代码行数:50,代码来源:chainbase.cpp


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