I tried creating the .gz file using poco functions but gives the negative ratio when given to gzip
gzip -l simple.gzip compressed uncompressed ratio uncompressed_name 106 42 -90.5% simple.gzip
#include <stdexcept>
#include <stdarg.h>
#include <map>
#include <iostream>
#include <cstring>
#include <fstream>
#include <Poco/DeflatingStream.h>
#include <stdio.h>
#include <limits>
#include <stdio.h>
#include <unistd.h>
using namespace std;
int main(){
std::ofstream* ostr;
Poco::DeflatingOutputStream* ofstr;
string fileName="/home/lamb/Cpp/simple.gzip";
ostr = new std::ofstream;
ostr->exceptions(std::ofstream::failbit|std::ofstream::badbit);
ostr->open(_fileName.c_str(), std::ios::binary | std::ios::app);
ofstr = new Poco::DeflatingOutputStream(*_ostr,
Poco::DeflatingStreamBuf::STREAM_GZIP);
ofstr->precision(std::numeric_limits<double>::digits10);
*ofstr << "\t<xyz>\n";
*ofstr << "\t</xyz>\n";
*ofstr << " who=\"";
*ofstr << "/>\n";
ofstr->close();
delete ofstr;
ofstr = NULL;
ostr->close();
delete ostr;
ostr = NULL;
ostr = new std::ofstream;
ostr->exceptions(std::ofstream::failbit|std::ofstream::badbit);
ostr->open(fileName.c_str(), std::ios::binary | std::ios::app);
ofstr = new Poco::DeflatingOutputStream(*ostr,
Poco::DeflatingStreamBuf::STREAM_GZIP);
ofstr->precision(std::numeric_limits<double>::digits10);
*ofstr << "\t<xyz>\n";
*ofstr << "\t</xyz>\n";
*ofstr << " hello=\"";
*ofstr << "/>\n";
ofstr->close();
ostr->close();
delete ofstr;
delete ostr;
}
Aucun commentaire:
Enregistrer un commentaire