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


C++ path_t::string方法代码示例

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


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

示例1: read

void read(std::basic_string<CharT>& buf, path_t const& path)
{
    std::basic_string<char> buf_;
    std::basic_ifstream<char> ifs(path.string());
    ifs.imbue(std::locale(""));

    if (!ifs) {
        throw file_error("failed to open file " + path.string());
    }

    // get length
    ifs.seekg(0, std::ios::end);
    auto const len = ifs.tellg();
    ifs.seekg(0, std::ios::beg);

    buf_.resize(len);
    ifs.read(&buf_[0], len);

    buf = to<std::basic_string<CharT>>(buf_);
}
开发者ID:saki7,项目名称:saya,代码行数:20,代码来源:file.hpp

示例2: stat_filesize

  uint64_t file_manager::stat_filesize(path_t const& p) const
  {
    std::ifstream fp(p.string().c_str(), std::ios_base::binary);
    if (!fp.is_open() || !fp.good())
      return 0;

    uint64_t size = stat_filesize(fp);

    fp.close();

    return size;
  }
开发者ID:amireh,项目名称:Karazeh,代码行数:12,代码来源:file_manager.cpp

示例3: fp

  bool
  downloader::fetch(string_t const& url, path_t const& path, string_t const& checksum, int* const retry_tally) const
  {
    // TODO: rethink about this, this really sounds like an external concern
    for (int i = 0; i < retry_count_ + 1; ++i) {
      bool fetch_successful;

      if (!file_manager_.is_writable(path)) {
        error() << "Download destination is un-writable: " << path;
        return false;
      }

      std::ofstream fp(path.string().c_str(), std::ios_base::trunc | std::ios_base::binary);

      if (retry_tally != nullptr) {
        (*retry_tally) = i;
      }

      fetch_successful = fetch(url, fp);

      fp.close();

      if (fetch_successful) {
        if (!file_manager_.is_readable(path)) {
          return false; // this really shouldn't happen, but oh well
        }

        // validate integrity
        hasher::digest_rc rc = config_.hasher->hex_digest(path);

        if (rc == checksum) {
          return true;
        }
        else {
          warn()
            << "Downloaded file integrity mismatch: "
            <<  rc.digest << " vs " << checksum;
        }
      }

      notice() << "Retry #" << i+1;
    }

    return false;
  }
开发者ID:amireh,项目名称:Karazeh,代码行数:45,代码来源:downloader.cpp

示例4: load_file

 bool file_manager::load_file(path_t const& path, string_t& out_buf) const
 {
   return load_file(path.string(), out_buf);
 }
开发者ID:amireh,项目名称:Karazeh,代码行数:4,代码来源:file_manager.cpp


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