Building support and size support.

This commit is contained in:
2026-07-21 23:40:50 -04:00
parent 68969322d0
commit 1a1364ec7c
4 changed files with 41 additions and 12 deletions
+12 -5
View File
@@ -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 << "";
for( int i= 0; i < rowWidth; ++i ) std::cout << "\u2500";
@@ -44,13 +49,15 @@ main()
std::cout << format_entry( entry, widest ) << " ";
if( entry.is_dir )
{
std::cout << "<dir>";
std::cout << "";
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 << " ";
std::cout << " ";
std::cout << "" << entry.perms << "";
std::cout << " ";
if( side == false )