Project

General

Profile

« Previous | Next » 

Revision 13f1ac5a

Added by David Sorber almost 8 years ago

Minor formatting changes for running status output.

View differences:

software/photo_compress_archiver/PhotoCompressArchiver.cc
#include <iostream>
#include <limits.h>
#include <thread>
#include <sstream>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
......
// Display status
std::cout << BOLD << "\n>>> Status:" << ENDC << std::endl;
std::string line(100, '-');
std::cout << line << std::endl;
std::cout << LINE << std::endl;
if (! m_verbose)
{
// If not in verbose mode display running status
......
double ratio = ((double)m_total_compressed_size /
m_running_compressed_size) * 100;
// This looks odd but in fact checks for NaN which we don't want to
// display in the status
if (ratio != ratio)
{
ratio = 0.0;
}
// Highlight and non-zero number of errors in bold red for emphasis
uint32_t num_errors = m_errors.size();
std::ostringstream formatted_errors;
if (num_errors > 0)
{
formatted_errors << "Errors: " << BOLD << RED << num_errors
<< ENDC;
}
else
{
formatted_errors << "Errors: " << num_errors ;
}
std::cout << "Elapsed time: " << std::fixed
<< std::setprecision(3) << duration << " s "
<< "Files processed: "
<< m_files_processed << " / "
<< m_num_input_files << " "
<< "Errors: " << num_errors << " "
<< formatted_errors.str() << " "
<< std::endl;
pbar.update(std::lround(percent_done));
......
<< std::setprecision(2) << ratio << "% "
<< std::endl;
std::cout << line << std::endl;
std::cout << LINE << std::endl;
// Delay slightly to prevent flickering
// Delay slightly to prevent cursor flickering
if (percent_done < 100.0)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));

Also available in: Unified diff