summaryrefslogtreecommitdiff
path: root/MegamanX5/unarc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MegamanX5/unarc.cpp')
-rw-r--r--MegamanX5/unarc.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/MegamanX5/unarc.cpp b/MegamanX5/unarc.cpp
index c9ab2be..38a6522 100644
--- a/MegamanX5/unarc.cpp
+++ b/MegamanX5/unarc.cpp
@@ -1,40 +1,40 @@
#include <stdlib.h>
#include "generic.h"
-#include "fileutils.h"
+#include "Input.h"
+#include "Output.h"
+#include "Main.h"
-int main(int argc, char ** argv) {
- FILE * f;
+CODE_BEGINS
+int startup() {
+ Handle * f, * o;
int i = 0;
- f = fopen(argv[1], "r");
+ f = new Input(argv[1]);
int offset = 0;
while (1) {
int sector, size;
- fseek(f, offset, SEEK_SET);
- fread(&sector, 4, 1, f);
- fread(&size, 4, 1, f);
+ f->seek(offset, SEEK_SET);
+ f->read(&sector, 4);
+ f->read(&size, 4);
offset += 8;
if (!sector)
break;
- fseek(f, sector <<= 9, SEEK_SET);
+ f->seek(sector <<= 9, SEEK_SET);
- char * buffer = (char *) malloc(size);
-
- fread(buffer, 1, size, f);
-
- char fname[64];
- sprintf(fname, "unarc-%03i.out", i);
- FILE * o = fopen(fname, "w");
- fwrite(buffer, 1, size, o);
- fclose(o);
+ String fname;
+ fname.set("unarc-%03i.out", i);
+ o = new Output(fname);
+ copy(f, o, size);
+ delete o;
i++;
-
- free(buffer);
}
- exit(-1);
+ delete f;
+
+ return -1;
}
+CODE_ENDS