37 #ifndef LIB_STAT_FILE_H 38 #define LIB_STAT_FILE_H 52 extern const string UNIX_HOMEDIR_SYMBOL;
59 auto home = std::getenv(UNIX_HOMEDIR_ENV);
62 return fs::path{home};
74 if (UNIX_HOMEDIR_SYMBOL == *rawPath.begin())
75 rawPath = getHomePath() / rawPath.lexically_proximate(UNIX_HOMEDIR_SYMBOL);
77 return fs::exists(rawPath)? fs::absolute(
78 fs::canonical(rawPath))
85 has_perm (fs::path
const& p, fs::perms permissionMask)
87 return (fs::status(p).permissions() & permissionMask) == permissionMask;
94 return has_perm (p, fs::perms::owner_read);
98 can_write (fs::path
const& p)
100 return has_perm (p, fs::perms::owner_write);
104 can_exec (fs::path
const& p)
106 return has_perm (p, fs::perms::owner_exec);
119 invoke (fs::path path) noexcept
121 return "≺"+std::string{path}+
"≻";
124 {
return lib::meta::FAILURE_INDICATOR; }
fs::path consolidated(fs::path rawPath)
resolves symlinks, ~ (Unix home dir) and relative specs
bool has_perm(fs::path const &p, fs::perms permissionMask)
check if the denoted path p has at least the given permissions
inline string literal This is a marker type to indicate that
bool can_read(fs::path const &p)
check if the owner has read permissions on the denoted file or directory
Derived specific exceptions within Lumiera's exception hierarchy.
Marker types to indicate a literal string and a Symbol.
Lumiera error handling (C++ interface).
failsafe invocation of custom string conversion.