Respect size, print summary.
This commit is contained in:
@@ -35,7 +35,7 @@ getEntries( const std::filesystem::path where )
|
|||||||
|
|
||||||
namespace C
|
namespace C
|
||||||
{
|
{
|
||||||
constexpr int dirwidth= 9;
|
constexpr int sizeWidth= 14;
|
||||||
constexpr int dateWidth= "82-12-21"s.size();
|
constexpr int dateWidth= "82-12-21"s.size();
|
||||||
constexpr int timeWidth= "12:34"s.size();
|
constexpr int timeWidth= "12:34"s.size();
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ main()
|
|||||||
const auto widest= std::max_element( begin( entries ), end( entries ),
|
const auto widest= std::max_element( begin( entries ), end( entries ),
|
||||||
[]( const auto &lhs, const auto &rhs ) { return lhs.name.size() < rhs.name.size(); } )->name.size();
|
[]( const auto &lhs, const auto &rhs ) { return lhs.name.size() < rhs.name.size(); } )->name.size();
|
||||||
|
|
||||||
const int rowWidth= widest + C::filePadding + C::dirwidth + 3 + 10 + 2 + C::dateWidth + 1 + C::timeWidth;
|
const int rowWidth= widest + C::filePadding + C::sizeWidth + 2 + 10 + 2 + C::dateWidth + 1 + C::timeWidth;
|
||||||
|
|
||||||
std::cout << "[1;36;96m";
|
std::cout << "[1;36;96m";
|
||||||
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
||||||
@@ -58,21 +58,26 @@ main()
|
|||||||
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
||||||
std::cout << "[m" << std::endl;
|
std::cout << "[m" << std::endl;
|
||||||
|
|
||||||
|
std::size_t fileCount= 0;
|
||||||
|
std::size_t totalSize= 0;
|
||||||
|
std::size_t totalStorage= 0;
|
||||||
bool side= false;
|
bool side= false;
|
||||||
for( const auto &entry: entries )
|
for( const auto &entry: entries )
|
||||||
{
|
{
|
||||||
|
++fileCount;
|
||||||
|
totalSize+= entry.size;
|
||||||
std::cout << format_entry( entry, widest ) << "[m ";
|
std::cout << format_entry( entry, widest ) << "[m ";
|
||||||
if( entry.is_dir )
|
if( entry.is_dir )
|
||||||
{
|
{
|
||||||
std::cout << "[1;35;95m";
|
std::cout << "[1;35;95m";
|
||||||
std::cout << std::setw( C::dirwidth - 2 ) << std::setfill( ' ' ) << std::right << "<DIR>" << ' ';
|
std::cout << std::setw( C::sizeWidth - 1 ) << std::setfill( ' ' ) << std::right << "<DIR>" << ' ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//std::cout << " ";
|
//std::cout << " ";
|
||||||
std::cout << "\e[1;33;93m" << std::setw( C::dirwidth - 1 ) << std::setfill( ' ' ) << entry.size;
|
std::cout << "\e[1;33;93m" << std::setw( C::sizeWidth ) << std::setfill( ' ' ) << entry.size;
|
||||||
}
|
}
|
||||||
std::cout << "[m ";
|
std::cout << "[m ";
|
||||||
std::cout << "[1;34;94m" << entry.perms << "[m";
|
std::cout << "[1;34;94m" << entry.perms << "[m";
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
|
||||||
@@ -110,5 +115,8 @@ main()
|
|||||||
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
||||||
std::cout << "[m" << std::endl;
|
std::cout << "[m" << std::endl;
|
||||||
|
|
||||||
|
std::cout << std::setw( C::sizeWidth ) << std::setfill( ' ' ) << std::right << "\e[;1;36;96m" << fileCount;
|
||||||
|
std::cout << "\e[;1;32;92m files totaling \e[;1;36;96m" << totalSize << "\e[;1;32;92m bytes.\e[m" << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user