There are 4 data streams, and the sizes you are reading from (offset 254) actually refer to the 4th one. What you want to read, or are reading, is the first data stream, so you need the sizes for that. I would suggest you read the first 262 bytes into a STRUCT of some sort, but if not you can always try the following amendments (marked in red):
Code:
if (fseek(file, (long int) 230, SEEK_SET) != 0) {
perror("Error setting the position for reading");
return 1;
}
if (fread(&compsize, 4, 1, file) == 0) {
perror("Could not read the size of the input stream");
return 1;
};
inputstream = malloc (compsize);
if (inputstream == NULL) {
perror("Could not allocate memory for the input stream");
return 1;
};
if (fread(&uncompsize, 4, 1, file) == 0) {
perror("Could not read the size of the output stream");
return 1;
}
fseek(file, 24, SEEK_CUR);
And I'll hopefully be releasing my classes soon, if I don't get lazy for some reason or another.
|