30 std::vector<unsigned char>
in;
34 in.push_back((
unsigned char)c);
42 uLongf destLen = compressBound(in.size());
43 int zerr = compress2(&*
blob.begin(), &destLen,
44 &*in.begin(), in.size(),
52 blob.push_back( (
unsigned char)c);
60 std::vector<unsigned char>
out(
isize);
61 uLongf destLen = out.size();
62 int zerr = uncompress(&*out.begin(), &destLen,
64 if (zerr!=0 || out.size()!=destLen)
66 <<
" original size was " <<
isize
67 <<
" new size is " << destLen;
68 os.write(reinterpret_cast<const char *>(&*out.begin()),out.size());
70 os.write(reinterpret_cast<const char *>(&*
blob.begin()),
blob.size());
75 std::unique_ptr<std::vector<unsigned char> > newblob;
78 newblob.reset(
new std::vector<unsigned char>(
isize));
79 uLongf destLen = newblob->size();
81 int zerr = uncompress(&*(newblob->begin()), &destLen,
83 if (zerr!=0 || newblob->size()!=destLen)
85 <<
" original size was " <<
isize
86 <<
" new size is " << destLen;
88 newblob.reset(
new std::vector<unsigned char>(
blob));
96 myblobcopy.reserve(
isize);
97 uLongf destLen =
isize;
98 int zerr = uncompress(&*myblobcopy.begin(), &destLen,
100 if (zerr!=0 || myblobcopy.size()!=destLen)
102 <<
" original size was " <<
isize
103 <<
" new size is " << destLen;
111 std::ifstream
ifile(fname.c_str());
118 std::ofstream
ofile(fname.c_str());
125 std::ifstream
ifile(fname.c_str());
135 while (is.get(c)) rs++;
std::vector< unsigned char > blob
static unsigned int computeFileSize(const std::string &)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
static unsigned int computeStreamSize(std::istream &)
void write(const std::string &) const
write to real file
void read(const std::string &)
read from real file
std::unique_ptr< std::vector< unsigned char > > getUncompressedBlob() const
i didn't want to do two copies ... hope this works.