char *inBuffer = new char[inStreamSize]; uncompressedBufferSize = inStreamSize*40; unCompressedBuffer = new char[uncompressedBufferSize]; inFile.read (inBuffer, inStreamSize); //inStreamSize = inFile.gcount(); zs = new z_stream; zs->next_in = (unsigned char *)inBuffer; //point to beginning of compressed file zs->avail_in = inFile.gcount(); //specify the size of the compressed file zs->next_out = (unsigned char *)unCompressedBuffer; //point to where the uncompressed file will be zs->avail_out = uncompressedBufferSize; //specify size of buffer to hold uncompressed file zs->zalloc = (alloc_func)0; zs->zfree = (free_func)0; zs->data_type = Z_BINARY; ret = inflateInit(zs); ret = inflate(zs, Z_FINISH); if(ret != Z_OK && ret != Z_STREAM_END) { AfxMessageBox("Failed to decompress file"); inFile.close(); outFile.close(); return TRUE; } ret = inflateEnd (zs); if(ret == Z_OK) { outFile.write (unCompressedBuffer, zs->total_out); m_ctrlFileProgress.StepIt(); CreateBMPFiles(unCompressedBuffer, zs->total_out); m_ctrlFileProgress.StepIt(); // m_ctrlFileProgress.StepIt(); CreateLogFile(unCompressedBuffer); m_ctrlFileProgress.StepIt(); } //cleanup: inFile.close(); outFile.close(); delete [] zs; delete[] unCompressedBuffer; delete[] inBuffer; } m_ctrlFileProgress.SetPos(4); SetDlgItemText(IDC_PROGRESS_TEXT, "1 File Converted"); AfxMessageBox("Decompression Complete"); return TRUE; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)