#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;}
Using the Boost mapped file