core123
asked on
zlib uncompression
In a program, I've imported the call "uncompress()" from zlib.dll using LoadLibrary(), then GetProcAddress() with the handle returned by LoadLibrary(). So now that I have support to call the function uncompress() from zlib.dll, how do I uncompress an entire file? For 500 points, I wanna see code example that I can copy and paste (with relatively few modifications) :)
Thanks!
Chris O.
Thanks!
Chris O.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
FILE* fileIn = fopen("YourFileIn.XXX", "r");
FILE* fileOut = fopen("YourFileOut.XXX", "w");
while (TRUE){
Byte bufferIn[1024];
uLong readB = fread((void*)bufferIn, 1024, 1, fileIn);
if (!readB) break;
Byte bufferOt[1024];
uLong writeB = 0;
YourUnompressFunction(buff erIn, readB, bufferOut, writeB);
uLong realWB = fwrite(bufferOut, writeB, 1, fileOut);
if ((readB < 1024) || (realWB < writeB)) break;
}
fclose(fileIn);
fclose(fileOut);
FILE* fileOut = fopen("YourFileOut.XXX", "w");
while (TRUE){
Byte bufferIn[1024];
uLong readB = fread((void*)bufferIn, 1024, 1, fileIn);
if (!readB) break;
Byte bufferOt[1024];
uLong writeB = 0;
YourUnompressFunction(buff
uLong realWB = fwrite(bufferOut, writeB, 1, fileOut);
if ((readB < 1024) || (realWB < writeB)) break;
}
fclose(fileIn);
fclose(fileOut);
ASKER