diff options
author | Pixel <Pixel> | 2002-08-25 14:39:48 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-08-25 14:39:48 +0000 |
commit | 38d60726082b04e79edae1c8c797c6dcb8314504 (patch) | |
tree | 4a056a158c6fc21c29dd8d8ed94c010a25cee19a /lzss-main.cpp | |
parent | 1b0a5db816b7610c83615e93095155b1709f55da (diff) |
Workiiiiiiiiiiiiiiiiiing!!!!
Diffstat (limited to 'lzss-main.cpp')
-rw-r--r-- | lzss-main.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/lzss-main.cpp b/lzss-main.cpp index 0d08cba..0a4a446 100644 --- a/lzss-main.cpp +++ b/lzss-main.cpp @@ -21,15 +21,15 @@ #include <stdlib.h> #include <string.h> #include <getopt.h> -#include <iostream> -#include "fileutils.h" +#include "Input.h" +#include "Output.h" #include "generic.h" #include "lzss.h" char * fn1, * fn2, * pname; int lga = 0; -int compress = 1; +int lzsscompress = 1; struct option long_options[] = { {"1iscomp", 1, &lga, 1 }, @@ -96,7 +96,7 @@ void showhelp(void) { "If you don't know what they are, forget them.\n" "\n" "Default behavior is to %scompress.\n" -"\n", pname, pname, pname, pname, compress ? "" : "de"); +"\n", pname, pname, pname, pname, lzsscompress ? "" : "de"); } void showscheme(void) { @@ -146,7 +146,7 @@ void dump(void) { int main(int argc, char ** argv) { long length = -1; - FILE * f1, * f2; + Handle * f1, * f2; int p, show = 0; int c, s, t; @@ -156,7 +156,7 @@ int main(int argc, char ** argv) { verbosity = M_STATUS; if (!strcasecmp(pname + p, "dlzss")) { - compress = 0; + lzsscompress = 0; } printm(M_BARE, /* @@ -317,10 +317,10 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ exit(0); break; case 'd': - compress = 0; + lzsscompress = 0; break; case 'c': - compress = 1; + lzsscompress = 1; break; case 'b': blockb = 1; @@ -347,21 +347,17 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ fn1 = argv[optind++]; fn2 = argv[optind++]; - if (!(f1 = fopen(fn1, "r"))) { - printm(M_ERROR, "Error opening file %s for reading.\n", fn1); - } + f1 = new Input(fn1); - if (!(f2 = fopen(fn2, "w"))) { - printm(M_ERROR, "Error opening file %s for writing.\n", fn2); - } + f2 = new Output(fn2); - if (compress) { + if (lzsscompress) { printm(M_STATUS, "Compressing `%s' to `%s'...\n", fn1, fn2); } else { printm(M_STATUS, "Decompressing `%s' to `%s'...\n", fn1, fn2); } - if (compress) { + if (lzsscompress) { if (length == -1) { lzss_comp(f1, f2); } else { @@ -371,14 +367,14 @@ LZSS_MAIN " compressor/decompressor version " LZSS_VERSION ",\n" */ length = lzss_decomp(f1, f2, length); } - printm(M_STATUS, "Done, filesize changed from %i to %i.\n", filesize(f1), filesize(f2)); + printm(M_STATUS, "Done, filesize changed from %i to %i.\n", f1->GetSize(), f2->GetSize()); if (!bitmap_count) bitmap_count = 8; - if (compress) + if (lzsscompress) printm(M_STATUS, "Compressed %i = 0x%08x blocs, containing %i = 0x%08x chunks.\n", blk + 1, blk + 1, blk * 8 + bitmap_count, blk * 8 + bitmap_count); - fclose(f1); - fclose(f2); + delete f1; + delete f2; exit(0); } |