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


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

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


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

示例1: copy_file

    inline
    void copy_file(const boost::filesystem::path& path_from,
                   const boost::filesystem::path& path_to)
    {
      // 4M bytes buffer...
      std::vector<char> buffer(4 * 1024 * 1024);

      int infile = 0;
      int outfile = 0;
      struct stat stat_from;

#if BOOST_FILESYSTEM_VERSION == 2
      const std::string file_from = path_from.native_file_string();
      const std::string file_to = path_to.native_file_string();
#else
      const std::string file_from = path_from.string();
      const std::string file_to = path_to.string();
#endif
      
      if (:: stat(file_from.c_str(), &stat_from) != 0
          || (infile = ::open(file_from.c_str(), O_RDONLY)) < 0
          || (outfile = ::open(file_to.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, stat_from.st_mode)) < 0) {

        if (infile >= 0) ::close(infile);
        throw std::runtime_error("copy file failed");
      }
      
      ssize_t sz = 0;
      ssize_t sz_read = 1;
      ssize_t sz_write = 0;
      
      while (sz_read > 0) {
        do
          sz_read = ::read(infile, &(*buffer.begin()), buffer.size());
        while (sz_read < 0 && errno == EINTR);

        if (sz_read <= 0) break;

        sz_write = 0;
        do {
          if ((sz = ::write(outfile, &(*(buffer.begin() + sz_write)), sz_read - sz_write)) < 0) {
            if (errno == EINTR)
              continue;
            else {
              sz_read = sz;
              break;
            }
          }
          sz_write += sz;
        } while (sz_write < sz_read);
      }
      if ( ::close( infile) < 0 ) sz_read = -1;
      if ( ::close( outfile) < 0 ) sz_read = -1;

      if ( sz_read < 0 )
        throw std::runtime_error("copy file failed");
    }
开发者ID:hitochan777,项目名称:cicada,代码行数:57,代码来源:filesystem.hpp

示例2: system_error_prep

 std::string system_error_prep(
   const std::string & who,
   const fs::path & path1,
   const fs::path & path2,
   int sys_err_code )
 {
   return who + ": \"" + path1.native_file_string()
     + "\", \"" + path2.native_file_string() + "\": "
     + system_message( sys_err_code );
 }
开发者ID:hackshields,项目名称:antivirus,代码行数:10,代码来源:exception.cpp

示例3: open

void fileview::open(const boost::filesystem::path& p)
{
   cow();
   std::ifstream is(p.native_file_string().c_str());
   if(!is)
   {
      std::string msg("Bad file name: ");
      msg += p.native_file_string();
      std::runtime_error e(msg);
      boost::throw_exception(e);
   }
   std::istreambuf_iterator<char> in(is);
   std::istreambuf_iterator<char> end;
   std::copy(in, end, std::back_inserter(pimpl->m_data));
}
开发者ID:CambrianTech,项目名称:boost-build,代码行数:15,代码来源:fileview.cpp

示例4:

    sheet_tracker(const bfs::path& sheet_path,
                  const bfs::path& input_path) :
        callbacks_m(adobe::bind_to_sheet(sheet_m))
    {
        //  attach the VM to the sheet.
        sheet_m.machine_m.set_variable_lookup(boost::bind(&adobe::sheet_t::get, &sheet_m, _1));
    
        std::string     sheet_path_str(sheet_path.native_file_string());
        std::ifstream   sheet_stream(sheet_path_str.c_str());

        callbacks_m.add_cell_proc_m = 
            boost::bind(&sheet_tracker::add_cell_trap, boost::ref(*this), 
                        callbacks_m.add_cell_proc_m, _1, _2, _3, _4);
        callbacks_m.add_interface_proc_m =
            boost::bind(&sheet_tracker::add_interface_trap, boost::ref(*this), 
                        callbacks_m.add_interface_proc_m, _1, _2, _3, _4, _5, _6);

        if (!sheet_stream.is_open())
            std::cerr << "Could not open \"" << sheet_path_str << "\"!\n";

        // set up adam sheet
        adobe::parse(sheet_stream,
                     adobe::line_position_t("property model sheet"),
                     callbacks_m);

        sheet_m.set(parse_input_dictionary(input_path));

        sheet_m.update();
    }
开发者ID:apextw,项目名称:Ramen,代码行数:29,代码来源:main.cpp

示例5: parse_input_dictionary

adobe::dictionary_t parse_input_dictionary(const bfs::path& input_path)
{
    std::string              path_str(input_path.native_file_string());
    std::ifstream            input_stream(path_str.c_str());
    adobe::array_t           token_stream;
    adobe::virtual_machine_t vm;

    if (!adobe::expression_parser(input_stream,
                                  adobe::line_position_t("input_dictionary")).is_expression(token_stream))
        return adobe::dictionary_t();

    vm.evaluate(token_stream);

    const adobe::dictionary_t result(vm.back().cast<adobe::dictionary_t>());

    vm.pop_back();

    std::cout << "--" << std::endl
              << "Initializing sheet with the following input dictionary: "
              << adobe::begin_asl_cel << result << adobe::end_asl_cel
              << std::endl
              << "--" << std::endl;

    return result;
}
开发者ID:apextw,项目名称:Ramen,代码行数:25,代码来源:main.cpp

示例6: other_error_prep

 std::string other_error_prep(
   const std::string & who,
   const fs::path & path1,
   const std::string & message )
 {
   return who + ": \"" + path1.native_file_string() + "\": " + message;
 }
开发者ID:hackshields,项目名称:antivirus,代码行数:7,代码来源:exception.cpp

示例7: load

xmlDocPtr XMLSubstitute::load( const ::boost::filesystem::path& xmlFile)
{
#if BOOST_FILESYSTEM_VERSION > 2
    xmlDocPtr doc = xmlParseFile(  xmlFile.string().c_str() );
#else
    xmlDocPtr doc = xmlParseFile(  xmlFile.native_file_string().c_str() );
#endif

    if ( ! m_dictionary.empty() ) // dictionary empty => classic xmlParseFile()
    {
        xmlNodePtr original = xmlDocGetRootElement(doc);
        // create the context for xpath
        xmlXPathContextPtr xpathCtx;
        xpathCtx = xmlXPathNewContext(doc);
        SLM_ASSERT("xpathCtx not instanced", xpathCtx);

        xmlChar *xpathExpr= BAD_CAST "//Substitutions";
        xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);

        if(xpathObj->nodesetval->nodeNr > 0)
        {
            // substitution node exists perform the translation
            SLM_ASSERT("XMLSubstitute::load manage only one xmlNode substitution", xpathObj->nodesetval->nodeNr == 1);
            xmlNodePtr substitutionRules = xpathObj->nodesetval->nodeTab[0];
            substitute(original, substitutionRules, m_dictionary);
        }
    }

    return doc;
}
开发者ID:dragonlet,项目名称:fw4spl,代码行数:30,代码来源:XMLSubstitute.cpp

示例8: create_parents

void create_parents( const fs::path &dpath )
{
  string     err( "create_parent(): " );
  fs::path       branch( dpath.branch_path() );
  string     who("create_parents");

  if( dpath.empty() ) {
    err.append( "cannot create an empty path." );

    throw CannotCreateParents( err );
  }
  else if( !exists(dpath) ) {
    if( branch.empty() ) create_directory( dpath );
    else if( !exists(branch) ) {
      create_parents( branch );
      create_directory( dpath );
    }
    else if( is_directory(branch) ) create_directory( dpath );
    else {
      err.append( branch.native_file_string() ); err.append( " is not a directory." );

      throw CannotCreateParents( err );
    }
  }
  else if( !is_directory(dpath) ) {
    err.append( dpath.native_file_string() ); err.append( " is not a directory." );

    throw CannotCreateParents( err );
  }

  return;
}
开发者ID:ic-hep,项目名称:emi3,代码行数:32,代码来源:boost_fs_add.cpp

示例9:

    inline std::string native_file_string(boost::filesystem::path const& p)
    {
#if BOOST_FILESYSTEM_VERSION >= 3
        return p.string();
#else
        return p.native_file_string();
#endif
    }
开发者ID:41i,项目名称:hpx,代码行数:8,代码来源:filesystem_compatibility.hpp

示例10: open

void file::open( const boost::filesystem::path& p, const char* mode )
{
    close();
    m_path = p;
    m_file = fopen( p.native_file_string().c_str(), mode );
    if( !m_file )
        THROW_GPM_EXCEPTION( "Error opening file %1%: %2%", %p  %strerror(errno));
}
开发者ID:tempbottle,项目名称:GeneralPublicMarket,代码行数:8,代码来源:trx_file.cpp

示例11: load

bool Sound::load(fs::path const& filename)
{	
	//cerr << "Loading sound: " << filename.native_file_string() << endl;
	m_sound = FSOUND_Sample_Load( FSOUND_FREE, filename.native_file_string().c_str(), FSOUND_HW3D | FSOUND_FORCEMONO, 0, 0 );
	if ( m_sound )
	{
		return true;
	}
	return false;
}
开发者ID:a-sf-mirror,项目名称:gusanos,代码行数:10,代码来源:sound.cpp

示例12: read_file

std::string read_file(const boost::filesystem::path &path) {
    FILE *in = fopen(path.native_file_string().c_str(), "rb");
    if (in == NULL)
        throw std::exception("Cannot open manifest file");
    std::string buffer;
    while (!feof(in)) {
        size_t begin = buffer.size();
        buffer.resize(begin + BLOCK_SIZE);
        size_t read = fread(&buffer[begin], sizeof(char), BLOCK_SIZE, in);
        if (ferror(in))
            throw std::exception("Error reading manifest file");
        buffer.resize(begin + read);
    }
    fclose(in);
    if (ferror(in))
        throw std::exception("Error closing manifest file");
    return buffer;
}
开发者ID:lambda,项目名称:halyard,代码行数:18,代码来源:FileSet.cpp

示例13: open

	void file::open(boost::filesystem::path const& p, open_mode m)
	{
		assert(p.is_complete());
		m_impl->open(p.native_file_string().c_str(), impl::open_flags(m.m_mask));
	}
开发者ID:svn2github,项目名称:libtorrent-rasterbar,代码行数:5,代码来源:file_win.cpp

示例14: SaveImage

void SaveImage( boost::filesystem::path path, cv::Mat image )
{
    cv::imwrite( path.native_file_string(), image );
}
开发者ID:mikeroberts3000,项目名称:NeuralProcessReconstructionFromSparseUserScribbles,代码行数:4,代码来源:Main.cpp

示例15: SaveOpticalFlowMap

void SaveOpticalFlowMap( boost::filesystem::path opticalFlowMapPath, cv::Mat opticalFlowMap )
{
    std::ofstream file( opticalFlowMapPath.native_file_string().c_str(), std::ios::binary );
    file.write( (char*)opticalFlowMap.data, opticalFlowMap.rows * opticalFlowMap.cols * sizeof( cv::Vec2f ) );
    file.close();
}
开发者ID:mikeroberts3000,项目名称:NeuralProcessReconstructionFromSparseUserScribbles,代码行数:6,代码来源:Main.cpp


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