In order to make the code more concise, transfer is directly used to mount the transfer operation of two streams.
// Initialize the file input stream tb_stream_ref_t istream = streams ("/home/file.txt"); // initialize the file output stream tb_stream_ref_t ostream = tb_stream_init_from_file ("/home/file.gz ", tb_file_mode_rw | extract | tb_file_mode_binary | extract); // initialize the extract stream and use istream as the input tb_stream_ref_t fstream = extract (istream, batch, tb_zip_action_inflate, use istream as the input // tb_stream_ref_t fstream = tb_stream_init_filter_from_zip (istream, tb_zip_algo_gzip, tb_zip_action_deflate); // stream transmission, and decompress and compress if (istream & ostream & fstream) through fstream. {/* stores stream data, if every stream has not been opened by calling tb_stream_open * this will automatically enable it for you. In this way, the upper-layer interface is more concise and clear. ** the following three parameters are mainly used: the speed limit and progress information callback are described in detail later. * now you only need to pass null. ** save indicates the actual data size transmitted. If it fails, the following error is returned: -1 */tb_hong_t save = tb_transfer_done (fstream, ostream, 0, tb_null, tb_null);} // release stream data if (fstream) tb_stream_exit (fstream); If (istream) tb_stream_exit (istream); If (ostream) tb_stream_exit (ostream );
Extract files through streams