繁体   English   中英

增强内存映射文件:读写访问

[英]Boost Memory Mapped File : Read-Write Access

我正在初始化升压mapd_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::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

我错过了什么吗?

对于那些想要答案的人,我可以使用此代码解决问题。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM