Skip to content

Commit

Permalink
clean up of output
Browse files Browse the repository at this point in the history
  • Loading branch information
NivDeveloper committed Mar 21, 2023
1 parent 9a1a07c commit 823d37f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Binary file modified build/SimComp
Binary file not shown.
6 changes: 3 additions & 3 deletions src/SimComp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

int main(int argc, char** argv)
{
if (argc == 7 && strcmp(argv[1], "-c") == 0 && strcmp(argv[3], "-o") == 0)
if (argc >= 5 && strcmp(argv[1], "-c") == 0 && strcmp(argv[3], "-o") == 0)
{
//call compression function
std::cout << "compressing file..." << std::endl;
Expand All @@ -43,7 +43,7 @@ int main(int argc, char** argv)
auto stop = std::chrono::steady_clock::now();
if (comp != Z_OK)
{
std::cout << "error occured" << std::endl;
utils::zlibError(comp);
return -1;
}
fseek(in, 0L, SEEK_END);
Expand All @@ -68,7 +68,7 @@ int main(int argc, char** argv)
auto stop = std::chrono::steady_clock::now();
if (comp != Z_OK)
{
std::cout << "error occured" << std::endl;
utils::zlibError(comp);
return -1;
}
fseek(in, 0L, SEEK_END);
Expand Down
25 changes: 23 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace utils
std::cout << "input size:\t\t" << decomp << " bytes" << std::endl;
std::cout << "output size:\t\t" << comp << " bytes"<< std::endl;
std::cout << "Compression Ratio:\t" << std::setprecision(4) << (float(decomp)/float(comp)) << std::endl;
std::cout << "compression duration:\t" << elapsed.count() << " microseconds" << std::endl;
std::cout << "Compression duration:\t" << elapsed.count() << " microseconds" << std::endl;
}


Expand Down Expand Up @@ -134,7 +134,28 @@ namespace utils
std::cout << "input size:\t\t" << comp << " bytes" << std::endl;
std::cout << "output size:\t\t" << decomp << " bytes"<< std::endl;
std::cout << "Decompression Ratio:\t" << std::setprecision(4) << ((float(decomp)/float(comp))) << std::endl;
std::cout << "compression duration:\t" << elapsed.count() << " microseconds" << std::endl;
std::cout << "Decompression duration:\t" << elapsed.count() << " microseconds" << std::endl;
}

void zlibError(int ret)
{
std::cout << "zlib ERROR!: ";
switch (ret) {
case Z_ERRNO:
std::cout << "i/o Error.";
break;
case Z_STREAM_ERROR:
std::cout << "invalid compression level." << std::endl;
break;
case Z_DATA_ERROR:
std::cout << "invalid or incomplete deflate data" << std::endl;
break;
case Z_MEM_ERROR:
std::cout << "out of memory." << std::endl;
break;
case Z_VERSION_ERROR:
std::cout << "zlib version does not match between included header and link file." << std::endl;
}
}

}
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace utils
void compDiagnostics(char* inName, char* outname, size_t decomp, size_t comp, int level, std::chrono::duration<int64_t, std::micro> elapsed);
int decompress(FILE* source, FILE* dest);
void decompDiagnostics(char* inName, char* outname, size_t decomp, size_t comp, std::chrono::duration<int64_t, std::micro> elapsed);

void zlibError(int ret);


}

0 comments on commit 823d37f

Please sign in to comment.