Building support and size support.
This commit is contained in:
@@ -12,7 +12,7 @@ getEntries( const std::filesystem::path where )
|
||||
|
||||
for( const auto &entry: std::filesystem::directory_iterator{ where } )
|
||||
{
|
||||
entries.emplace_back( entry.path().filename(), drwx( entry ), entry.is_directory(), is_exe( entry ) );
|
||||
entries.emplace_back( entry.path().filename(), drwx( entry ), entry.is_directory() ? 0 : file_size( entry.path() ), entry.is_directory(), is_exe( entry ) );
|
||||
}
|
||||
|
||||
std::sort( begin( entries ), end( entries ), []( const auto &lhs, const auto &rhs ) { return lhs.name < rhs.name; } );
|
||||
@@ -20,6 +20,11 @@ getEntries( const std::filesystem::path where )
|
||||
return entries;
|
||||
}
|
||||
|
||||
namespace C
|
||||
{
|
||||
constexpr int dirwidth= 9;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -30,7 +35,7 @@ main()
|
||||
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 int rowWidth= widest + 8 + 5 + 3 + 10 + 2;
|
||||
const int rowWidth= widest + C::filePadding + C::dirwidth + 3 + 10 + 2;
|
||||
|
||||
std::cout << "[1;36;96m";
|
||||
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
|
||||
@@ -44,13 +49,15 @@ main()
|
||||
std::cout << format_entry( entry, widest ) << "[m ";
|
||||
if( entry.is_dir )
|
||||
{
|
||||
std::cout << "[1;35;95m<dir>";
|
||||
std::cout << "[1;35;95m";
|
||||
std::cout << std::setw( C::dirwidth - 2 ) << std::right << "<DIR>" << ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << " ";
|
||||
//std::cout << " ";
|
||||
std::cout << "\e[1;33;93m" << std::setw( C::dirwidth - 1 ) << entry.size;
|
||||
}
|
||||
std::cout << "[m ";
|
||||
std::cout << "[m ";
|
||||
std::cout << "[1;34;94m" << entry.perms << "[m";
|
||||
std::cout << " ";
|
||||
if( side == false )
|
||||
|
||||
Reference in New Issue
Block a user