Split things up a bit.

Also start approximating the look and feel
This commit is contained in:
2026-05-20 22:32:42 -04:00
parent 82ca0de82d
commit 2c39765a4d
5 changed files with 130 additions and 67 deletions
+39
View File
@@ -0,0 +1,39 @@
#include "Entry.h"
#include <sstream>
#include <algorithm>
#include <filesystem>
bool
is_exe( const std::filesystem::directory_entry entry )
{
using std::filesystem::perms;
auto p= status( entry.path() ).permissions();
return ( perms::none != ( p & ( perms::owner_exec | perms::group_exec | perms::others_exec ) ) );
}
std::string
drwx( const std::filesystem::directory_entry entry )
{
auto p= status( entry.path() ).permissions();
std::ostringstream oss;
using std::filesystem::perms;
auto show = [&](const char op, const perms perm)
{
oss << (perms::none == (perm bitand p) ? '-' : op);
};
oss << ( entry.is_directory() ? 'd' : '-' );
show('r', perms::owner_read);
show('w', perms::owner_write);
show('x', perms::owner_exec);
show('r', perms::group_read);
show('w', perms::group_write);
show('x', perms::group_exec);
show('r', perms::others_read);
show('w', perms::others_write);
show('x', perms::others_exec);
return std::move( oss ).str();
}