计算资料crc32(精简版)

计算文件crc32(精简版)#include boost/iostreams/device/mapped_file.hpp //文件内存映射#include boos

计算文件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();
}