10 typedef unsigned int u_int32_t;
19 int main(int argc, char **argv)
26 printf("dumbass, specify filename to unpack\n");
30 fd = open(argv[1], O_RDONLY);
32 perror("open datafile");
35 /* get number of entries */
36 read(fd, &num_entries, 4);
38 printf("%d entries in datafile\n", num_entries);
40 datafile = calloc(num_entries, sizeof(DirEntry));
41 read(fd, datafile, num_entries * sizeof(DirEntry));
42 printf("Directory Listing:\n");
43 for (i = 0; i < num_entries; i++) {
45 memset(filename, 0, sizeof(filename));
46 strncpy(filename, datafile[i].filename, 12);
47 printf("%02d:\t%s (%u bytes)\n", i, filename,
51 for (i = 0; i < num_entries; i++) {
55 memset(filename, 0, sizeof(filename));
56 strncpy(filename, datafile[i].filename, 12);
57 printf("Extracting %s ", filename);
59 outfd = open(filename, O_RDWR | O_CREAT, 0644);
61 perror("cant open file");
64 lseek(fd, datafile[i].offset, SEEK_SET);
65 buf = calloc(1, datafile[i].size + 16);
66 read(fd, buf, datafile[i].size);
67 write(outfd, buf, datafile[i].size);