]> git.llucax.com Git - z.facultad/75.06/jacu.git/commitdiff
Hago que imprima bpb al terminar :)
authorLeandro Lucarella <llucax@gmail.com>
Mon, 21 Jun 2004 22:04:18 +0000 (22:04 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Mon, 21 Jun 2004 22:04:18 +0000 (22:04 +0000)
src/jacu.c

index fc4188f0f0b2916c7ab52734c0a35bc7bd4709cf..fe9499847316777a43d5c07aa4a54eac905536b0 100644 (file)
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <unistd.h>
 
+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;
+}
+