Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct MemFile
- {
- std::vector<unsigned char> bytes;
- std::vector<unsigned char> zip;
- void clear() { bytes.clear(); zip.clear(); }
- void pack()
- {
- int zip_size = bytes.size()*1.2;
- if (zip_size < 1000)
- zip_size = 1000;
- zip.resize(zip_size);
- unsigned int destLen;
- compress(&zip[0], (unsigned int*)&destLen, &bytes[0], (unsigned int)bytes.size());
- zip.resize(destLen);
- }
- };
- int fwrite(void *buffer, int size, int count, MemFile*f)
- {
- int last_size = f->bytes.size();
- f->bytes.resize(last_size + size * count);
- memcpy(&(f->bytes[last_size]), buffer, size * count);
- return size * count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement