读书人

计算资料crc32(精简版)

发布时间: 2012-09-29 10:30:01 作者: rapoo

计算文件crc32(精简版)

#include <boost/iostreams/device/mapped_file.hpp> //文件内存映射

#include <boost/crc.hpp> //冗余校验

unsigned long crc32file(const char* szFileName)
{
boost::iostreams::mapped_file _mapfile(szFileName);
if (!_mapfile.is_open())
return 0;

boost::crc_32_type _crc32type;
_crc32type.process_bytes(_mapfile.data(),_mapfile.size());
_mapfile.close();
return _crc32type.checksum();
}

读书人网 >编程

热点推荐