Split things up a bit.
Also start approximating the look and feel
This commit is contained in:
+39
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user