Commit 273b1678 by Rudolf

Compare original vs encoded file sizes

parent eb9ada04
Showing with 10 additions and 1 deletions
...@@ -140,9 +140,16 @@ int main(int argc, char *argv[]) ...@@ -140,9 +140,16 @@ int main(int argc, char *argv[])
if (decompress) if (decompress)
ret = decode_file(input, output); ret = decode_file(input, output);
else else {
ret = encode_file(input, output); ret = encode_file(input, output);
long insize = get_file_size(input);
long outsize = get_file_size(output);
printf("Original file size: %ld bytes\n", insize);
printf("Huffman file size: %ld bytes\n", outsize);
}
fclose(input); fclose(input);
fclose(output); fclose(output);
return ret; return ret;
......
...@@ -35,6 +35,8 @@ struct tree *create_tree(FILE *file) ...@@ -35,6 +35,8 @@ struct tree *create_tree(FILE *file)
if (c == EOF || c > MY_BUF-1) if (c == EOF || c > MY_BUF-1)
break; break;
/* While theoretically these files *can* be supported, Huffman is meant
* for text encoding/decoding, so we don't give a sh. */
if (c > MY_BUF-1 || c == EOF_CHAR) { if (c > MY_BUF-1 || c == EOF_CHAR) {
fprintf(stderr, "File not supported\n"); fprintf(stderr, "File not supported\n");
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment