【问题标题】:Boost Memory Mapped File : Read-Write Access提升内存映射文件:读写访问
【发布时间】:2014-12-06 06:14:34
【问题描述】:

我正在初始化 boost mapped_file_params,如下所示。

mapped_file_params param;
param.path = _fileName.c_str();
param.flags = mapped_file::readwrite;
int nGranularity = mapped_file::alignment();
//! must be in multiples of Granularity.
param.offset =  5*nGranularity;

当我打开具有文件大小的文件时,我得到一个 std::exception 读取“最多可以指定 'mode 和 'flags 之一”。我没有从 boost 的文档中填充模式,它说该模式已被弃用。建议进一步的新代码应该使用标志。

我的 boost 文件类型定义为

boost::iostreams::mapped_file _bioFile;

我已尝试使用打开文件

_bioFile.open(param, filesize);

提升 IO 文档:http://www.boost.org/doc/libs/1_57_0/libs/iostreams/doc/classes/mapped_file.html

我是不是错过了什么。

【问题讨论】:

    标签: c++ boost memory-mapped-files


    【解决方案1】:

    对于那些想要答案的人,我能够用这段代码解决问题。

    _bioFile.open(_fileName.c_str(), std::ios_base::in | std::ios_base::out, filesize);
    

    【讨论】:

      猜你喜欢
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-23
      • 2020-11-09
      • 2019-01-18
      • 1970-01-01
      相关资源
      最近更新 更多