THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/09/2008 at 21:22, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R9.5-R11
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Okay, a simple question:
Does UncompressData() understand partial buffers due to file reads for zlib decompression?
I'm reading a set number of bytes (per round) from a zlib-compressed file and then calling UncompressData(). So far, it always errors out at UncompressData(). I assume that the pDestData argument returns a pointer to a memory buffer that C4D allocated (thus the required GeFree()). ZBUFLEN = 65536L. I'm sorry - it is not possible to expect to be able to allocate a memory buffer to hold possible files (they may be in the hundreds of Megabytes!). Here's the method involved:
> // Decompress infile into outfile, return outfile \> //\*---------------------------------------------------------------------------\* \> Bool myZLib::DecompressFile(const Filename& inname, const Filename& outname, char\* buf) \> //\*---------------------------------------------------------------------------\* \> { \> AutoAlloc<BaseFile> out; \> AutoAlloc<BaseFile> in; \> if (!(in && out)) return FALSE; \> \> if (!in->Open(inname, GE_READ, FILE_NODIALOG, GE_INTEL)) \> { \> GePrint("Error: in->Open"); \> return FALSE; \> } \> if (!out->Open(outname, GE_WRITE, FILE_NODIALOG, GE_INTEL)) \> { \> GePrint("Error: out->Open"); \> return FALSE; \> } \> #ifdef OS64 \> VLONG len; \> #else \> LONG len; \> #endif \> LONG olen; \> char\* obuf; \> for (;;) \> { \> len = in->ReadBytes(buf, ZBUFLEN); \> if (len < 0) \> { \> GePrint("Error: len < 0"); \> return FALSE; \> } \> if (len == 0) return TRUE; \> if (!UncompressData(buf, len, (void\*&)obuf, olen)) \> { \> GePrint("Error: UncompressData"); // ALWAYS ERRORS HERE! \> return FALSE; \> } \> if (!out->WriteBytes(obuf, olen)) \> { \> GeFree(obuf); \> GePrint("Error: WriteBytes"); \> return FALSE; \> } \> GeFree(obuf); \> } \> if (!out->Close()) \> { \> GePrint("Error: out->Close"); \> return FALSE; \> } \> if (!in->Close()) \> { \> GePrint("Error: in->Close"); \> return FALSE; \> } \> return TRUE; \> }
Thanks,