From 74a725da69a939e4938082e676abde3e4009141a Mon Sep 17 00:00:00 2001 From: Paul Cruz Date: Wed, 21 Jun 2017 12:27:20 -0700 Subject: [PATCH 1/3] reversed calculation of ratio --- programs/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index a5db88a4..a0510f62 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1009,10 +1009,10 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLevel){ double const compressedSizeMB = (double)info->compressedSize/(1 MB); double const decompressedSizeMB = (double)info->decompressedSize/(1 MB); + double const ratio = (info->compressedSize == 0) ? 0 : ((double)info->decompressedSize)/info->compressedSize; const char* const checkString = (info->usesCheck ? "XXH64" : "None"); if (displayLevel <= 2) { if (!info->decompUnavailable) { - double const ratio = (info->decompressedSize == 0) ? 0.0 : compressedSizeMB/decompressedSizeMB; DISPLAYOUT("Skippable Non-Skippable Compressed Uncompressed Ratio Check Filename\n"); DISPLAYOUT("%9d %13d %7.2f MB %9.2f MB %5.3f %5s %s\n", info->numSkippableFrames, info->numActualFrames, compressedSizeMB, decompressedSizeMB, @@ -1030,7 +1030,7 @@ static void displayInfo(const char* inFileName, fileInfo_t* info, int displayLev DISPLAYOUT("Compressed Size: %.2f MB (%llu B)\n", compressedSizeMB, info->compressedSize); if (!info->decompUnavailable) { DISPLAYOUT("Decompressed Size: %.2f MB (%llu B)\n", decompressedSizeMB, info->decompressedSize); - DISPLAYOUT("Ratio: %.4f\n", compressedSizeMB/decompressedSizeMB); + DISPLAYOUT("Ratio: %.4f\n", ratio); } DISPLAYOUT("Check: %s\n", checkString); DISPLAYOUT("\n"); From 6f5fe71041d23271fc2409add38250c915b8c4ca Mon Sep 17 00:00:00 2001 From: Paul Cruz Date: Wed, 21 Jun 2017 12:37:23 -0700 Subject: [PATCH 2/3] added error check for when file could not be opened --- programs/fileio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/programs/fileio.c b/programs/fileio.c index a0510f62..634a888c 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -875,13 +875,14 @@ typedef struct { /* * Reads information from file, stores in *info * if successful, returns 0, returns 1 for frame analysis error, returns 2 for file not compressed with zstd + * returns 3 for cases in which file could not be opened. */ static int getFileInfo(fileInfo_t* info, const char* inFileName){ int detectError = 0; FILE* const srcFile = FIO_openSrcFile(inFileName); if (srcFile == NULL) { DISPLAY("Error: could not open source file %s\n", inFileName); - return 1; + return 3; } info->compressedSize = (unsigned long long)UTIL_getFileSize(inFileName); /* begin analyzing frame */ @@ -1056,6 +1057,10 @@ static int FIO_listFile(const char* inFileName, int displayLevel, unsigned fileN } return 1; } + else if (error == 3) { + /* error occurred with opening the file */ + return 1; + } displayInfo(inFileName, &info, displayLevel); return error; } From 5be0f5544e46182168ce83a06b968f63eeabda30 Mon Sep 17 00:00:00 2001 From: Paul Cruz Date: Wed, 21 Jun 2017 12:41:10 -0700 Subject: [PATCH 3/3] added newline to align output --- programs/fileio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/programs/fileio.c b/programs/fileio.c index 634a888c..0bcd1f87 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1059,6 +1059,9 @@ static int FIO_listFile(const char* inFileName, int displayLevel, unsigned fileN } else if (error == 3) { /* error occurred with opening the file */ + if (displayLevel > 2) { + DISPLAYOUT("\n"); + } return 1; } displayInfo(inFileName, &info, displayLevel);