标签:mapped_file_source mapped_file_params mapped_file_sink
#include <boost/iostreams/device/mapped_file.hpp> std::string src_path = "/Users/alex/Movies/m3u8_videos/dance.mp4"; std::string dst_path = "/Users/alex/Movies/m3u8_videos/dance-copy.mp4"; void copy_file() { boost::iostreams::mapped_file_params params_src; params_src.path = src_path; boost::iostreams::mapped_file_source mf_src; mf_src.open(params_src); if(mf_src.is_open()) { unsigned char* p_src = (unsigned char*)mf_src.data(); size_t len_src = mf_src.size(); boost::iostreams::mapped_file_params params_dst; params_dst.path = dst_path; params_dst.new_file_size = len_src; boost::iostreams::mapped_file_sink mf_dst; mf_dst.open(params_dst); if(mf_dst.is_open()) { unsigned char* p_dst = (unsigned char*)mf_dst.data(); for(size_t i = 0; i < len_src ; i++) { *(p_dst + i) = *(p_src + i); } mf_dst.close(); } mf_src.close(); } } int main() { <span style="white-space:pre"> </span>copy_file(); <span style="white-space:pre"> </span>return 0; }
标签:mapped_file_source mapped_file_params mapped_file_sink
原文地址:http://blog.csdn.net/dotphoenix/article/details/42495279