From 2ab683271e74b5cffc675da7f5b9e4b34bb4047c Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 21 Jun 2004 22:04:18 +0000 Subject: [PATCH] Hago que imprima bpb al terminar :) --- src/jacu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/jacu.c b/src/jacu.c index fc4188f..fe94998 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -8,6 +8,8 @@ #include #include +long get_file_size(const char* filename); + int main(int argc, char* argv[]) { int cflag = 0; @@ -117,6 +119,9 @@ int main(int argc, char* argv[]) /* borro el temporal */ unlink("tmp.comp"); + + /* Muestro bpb */ + printf("Comprimido a %.04f bpb.\n", get_file_size(argv[optind+1])*8.0/get_file_size(argv[optind])); return i; } @@ -158,3 +163,15 @@ int main(int argc, char* argv[]) return 0; } + +long get_file_size(const char* filename) +{ + FILE* file; + long file_size; + + if (!(file = fopen(filename, "ab"))) return -1; + file_size = ftell(file); + fclose(file); + return file_size; +} + -- 2.43.0