The structure is filled including name, file size, and offset into archive before that block of code is reached. That tiny for() loop simply extracts each file in turn. If you want to rewrite the extract_file() function to just do a simple lseek() and then read(), that's totally fine. Just make sure your buffer is big enough. Maybe something like:Code:for(i = 0;i < numfiles;++i)
extract_file(fdin, files[i]);
close(fdin);
Code:char *buffer;
for(i = 0;i < numfiles;++i)
{
buffer = malloc(files[i].size);
read(fdin, buffer, files[i].size);
fdout = open(...);
write(fdout, buffer, files[i].size);
close(fdout);
free(buffer);
}