17 #define WIN32_LEAN_AND_MEAN // optional
18 #include "filesystem.hpp"
21 namespace fs = ghc::filesystem;
26 size_t result =
static_cast<size_t>(fs::file_size(fs::path(
m_name),ec));
27 return ec ? 0 : result;
33 bool result = fs::exists(fs::path(
m_name),ec);
40 fs::file_status status = fs::status(
m_name,ec);
41 return !ec && (status.permissions() & fs::perms::owner_write)!=fs::perms::none;
47 fs::file_status status = fs::status(
m_name,ec);
48 return !ec && (status.permissions() & fs::perms::owner_read)!=fs::perms::none;
54 fs::file_status status = fs::status(
m_name,ec);
55 return !ec && (status.permissions() & fs::perms::owner_exec)!=fs::perms::none;
60 return fs::path(
m_name).is_relative();
66 fs::file_status status = fs::status(
m_name,ec);
67 return !ec && fs::is_regular_file(status);
73 fs::file_status status = fs::status(
m_name,ec);
74 return !ec && fs::is_directory(status);
80 fs::file_status status = fs::status(
m_name,ec);
81 return !ec && fs::is_symlink(status);
87 fs::path targetPath = fs::read_symlink(fs::path(
m_name));
88 return !ec ? targetPath.string() : std::string();
106 if (fs::exists(path,ec))
108 result = fs::canonical(path,ec).string();
112 result = (fs::current_path(ec) /
m_name).
string();
120 return fs::path(
m_name).filename().string();
126 size_t pos = s.find(
'.');
127 return pos!=std::string::npos ? s.substr(0,pos) : s;
133 size_t pos = complete ? fn.find(
'.') : fn.rfind(
'.');
134 return pos!=std::string::npos ? fn.substr(pos+1) : std::string();
149 size_t pos = result.rfind(
'/');
150 if (pos==std::string::npos)
160 return result.substr(0,pos);