I have written a code to read a .z compressed file directly. It works fine in linux and mac os. But it doesn't work as expected in windows.
#include <iostream>
#include <vector>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/zlib.hpp>
// cl /EHsc uncompress.cpp
std::vector<char> & readline(std::istream & stream, std::vector<char> & container) {
char c;
container.clear();
while (stream && stream.get(c)) {
container.push_back(c);
if (c == '\n') break;
}
return container;
}
int main () {
boost::iostreams::filtering_istream in;
boost::iostreams::filtering_istream cinn(std::cin);
in.push(boost::iostreams::zlib_decompressor());
in.push(cinn);
std::vector<char> line;
while (readline(in, line).size() != 0) {
std::string str(line.begin(), line.end());
std::cout << "--" << str ;
}
}
while running it as ./a.out < compressed.z
on linux or mac it works fine
while running it from windows uncompressed.exe < compressed.z
it doesn't show the content of the file.
Why is this behaving so ?