2014-12-06 78 views
0

我正在初始化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 ::例外閱讀「在最一個‘模式和’標誌可以指定」。我還沒有從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

我失去了一些東西。

回答

0

對於那些想要一個答案,我能夠解決這個代碼的問題。

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