Created
June 8, 2021 11:11
-
-
Save HanatoK/55dbbe6f80471cc68bdb47e33ee60c4c to your computer and use it in GitHub Desktop.
Read .xz file via boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main_boost.cpp | |
// g++ main_boost.cpp -o main_boost -lboost_iostreams | |
#include <boost/iostreams/filtering_stream.hpp> | |
#include <boost/iostreams/filter/lzma.hpp> | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
int main() { | |
const std::string filename("test.dat.xz"); | |
std::ifstream ifs_compressd_in(filename.c_str()); | |
if (!ifs_compressd_in.is_open()) { | |
std::cerr << "Error on opening file " << filename << std::endl; | |
return 1; | |
} | |
boost::iostreams::filtering_istream in; | |
in.push(boost::iostreams::lzma_decompressor()); | |
in.push(ifs_compressd_in); | |
std::string line; | |
while (std::getline(in, line)) { | |
std::cout << line << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment