diff options
author | Pixel <Pixel> | 2002-09-27 12:17:57 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-09-27 12:17:57 +0000 |
commit | bfa5de7eccf4604ff8217f619e9685a09e80d545 (patch) | |
tree | a5be5de750ac611145f459a09bda902c3dbc1a70 /VP/unarc.cpp | |
parent | 60c1003845035ad4cd0e9ea50862bad7626faf0e (diff) |
The week-without-the-network changes
Diffstat (limited to 'VP/unarc.cpp')
-rw-r--r-- | VP/unarc.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/VP/unarc.cpp b/VP/unarc.cpp index 5699260..7a22c48 100644 --- a/VP/unarc.cpp +++ b/VP/unarc.cpp @@ -2,14 +2,18 @@ #include <stdlib.h> #include <unistd.h> -#include "fileutils.h" +#include "Input.h" +#include "Output.h" #include "generic.h" +#include "Main.h" #define THRESHOLD 2000 -int main(int argc, char ** argv) { - int h, o, n, * index, * sizes, i, d; - char temp[100]; +CODE_BEGINS +int startup() { + int n, * index, * sizes, i, d; + String temp; + Handle * h, * o; verbosity = M_INFO; @@ -18,12 +22,9 @@ int main(int argc, char ** argv) { exit(-1); } - if ((h = open(argv[1], O_RDONLY)) < 0) { - printm(M_ERROR, "Unable to open archive file: %s\n", argv[1]); - exit(-1); - } + h = new Input(argv[1]); - read(h, &n, 4); + h->read(&n, 4); printm(M_STATUS, "Archive claims to have %i files, checking integrity.\n", n); @@ -36,8 +37,8 @@ int main(int argc, char ** argv) { sizes = (int *) malloc(n * sizeof(int)); for (i = 0; i < n; i++) { - lseek(h, (i + 1) * 8 + 4, SEEK_SET); - read(h, &(sizes[i]), 4); + h->seek((i + 1) * 8 + 4, SEEK_SET); + h->read(&(sizes[i]), 4); printm(M_INFO, "File #%i size = %i = 0x%08x\n", i, sizes[i], sizes[i]); } @@ -50,9 +51,9 @@ int main(int argc, char ** argv) { printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]); } - d = filesize(h) - index[n - 1] - sizes[n - 1]; + d = h->GetSize() - index[n - 1] - sizes[n - 1]; - printm(M_INFO, "Archive size: %i, last index: %i, last file size: %i, difference = %i\n", filesize(h), index[n - 1], sizes[n - 1], d); + printm(M_INFO, "Archive size: %i, last index: %i, last file size: %i, difference = %i\n", h->GetSize(), index[n - 1], sizes[n - 1], d); if ((d < 0) || (d > 2048)) { printm(M_ERROR, "Archive incoherent.\n"); @@ -62,15 +63,17 @@ int main(int argc, char ** argv) { printm(M_STATUS, "Archive seems to be ok, extracting.\n"); for (i = 0; i < n; i++) { - sprintf(temp, "%04i.out", i); - o = open(temp, O_WRONLY | O_CREAT | O_TRUNC, 0666); + temp.set("%04i.out", i); + o = new Output(temp); - printm(M_INFO, "Extracting %s\n", temp); + printm(M_INFO, "Extracting " + temp + "\n"); - lseek(h, index[i], SEEK_SET); + h->seek(index[i], SEEK_SET); copy(h, o, sizes[i]); - close(o); + delete o; } - exit(0); + delete h; + return 0; } +CODE_ENDS |