0
파일의 압축을 풀고 해당 내용을 stringstream에 쓰려고합니다.압축되지 않은 filtering_istream을 문자열 스트림에 복사하려고하면 오류가 발생합니다.
그것은 경고없이 컴파일string readGZipLog() {
try {
using namespace boost::iostreams;
ifstream file(currentFile.c_str(), std::ios_base::in | std::ios_base::binary);
boost::iostreams::filtering_istream in;
in.push(gzip_decompressor());
in.push(file);
std::stringstream strstream;
boost::iostreams::copy(in, strstream);
return strstream.str();
} catch (std::exception& e) {
cout << e.what() << endl;
}
}
void writeGZipLog (char* data) {
try {
using namespace boost::iostreams;
std::ofstream file(currentFile.c_str(), std::ios_base::out | std::ios_base::binary);
boost::iostreams::filtering_ostream out;
out.push(gzip_compressor());
out.push(file);
std::stringstream strstream;
strstream << data;
boost::iostreams::copy(strstream, data);
} catch (std::exception& e) {
cout << e.what() << endl;
}
}
(물론 오류의)하지만 함수를 실행하는 동안 readGZipLog()
충돌 :
이것은 내가 노력 코드는
gzip error
./build: line 3: 22174 Segmentation fault ./test
./build
스크립트입니다 응용 프로그램을 컴파일하고 시작합니다. ./test
자동으로
c 파일에 싫증이났다 : 무언가가 들어 있지만을 사용하여 압축을 풀 수 없다. 그래서 압축이 제대로 작동했는지, 그리고 Boost에 의해 throw 된 gzip error
과 관련이 있는지 확실하지 않습니다.
오류가 발생한 위치를 알려 줄 수 있습니까?
도움 주셔서 감사합니다.
폴