2c39765a4d
Also start approximating the look and feel
40 lines
974 B
C++
40 lines
974 B
C++
#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();
|
|
}
|