diff options
author | Pixel <Pixel> | 2002-05-04 17:53:08 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-05-04 17:53:08 +0000 |
commit | 24fb33726eca4e8c5a88797adc9c17f4d541f543 (patch) | |
tree | 72b385bd9e880e699e43c7db3ba12817f0e8e45e /Xenogears/archive.cpp |
Initial revision
Diffstat (limited to 'Xenogears/archive.cpp')
-rw-r--r-- | Xenogears/archive.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Xenogears/archive.cpp b/Xenogears/archive.cpp new file mode 100644 index 0000000..6701c2c --- /dev/null +++ b/Xenogears/archive.cpp @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <values.h> +#include <stdlib.h> +#include "fileutils.h" + +void dearchive(FILE * f) { + long nb; + long * address; + char fname[100]; + int i; + FILE * f_out; + + fread(&nb, 4, 1, f); + nb++; + fprintf(stderr, "Reading index... (%li elements)\n", nb); + + address = (long *) malloc(nb * sizeof(long) + 1); + + for (i = 0; i < nb; i++) { + fread(address + i, 4, 1, f); + } + address[nb] = MAXINT; + + for (i = 0; i < nb; i++) { + fprintf(stderr, "Dumping file %i\n", i); + sprintf(fname, "part-%i.lz", i); + f_out = fopen(fname, "wb"); + copy(fileno(f), fileno(f_out), address[i + 1] - address[i]); + fclose(f_out); + } + + free(address); +} + +int main(void) { + dearchive(stdin); +} |