add event key code base
This commit is contained in:
@@ -23,7 +23,7 @@ namespace rrr
|
||||
{
|
||||
public:
|
||||
file() = default;
|
||||
file(std::filesystem::path, file_type, bool);
|
||||
file(std::filesystem::path, file_type, bool, bool);
|
||||
file(file&&);
|
||||
file(const file&);
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace rrr
|
||||
std::filesystem::path path;
|
||||
file_type type;
|
||||
bool is_link = false;
|
||||
bool is_hidden = false;
|
||||
bool is_mark = false;
|
||||
};
|
||||
}
|
||||
@@ -46,6 +47,14 @@ namespace rrr::file_utils
|
||||
{
|
||||
using files = std::vector<file>;
|
||||
|
||||
inline bool is_hidden(const std::filesystem::path &p)
|
||||
{
|
||||
std::filesystem::path::string_type name = p.filename();
|
||||
if(name != ".." && name != "." && name[0] == '.')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
struct filesystem_convert
|
||||
{
|
||||
file operator()(const std::filesystem::directory_entry& entry) const
|
||||
@@ -56,8 +65,9 @@ namespace rrr::file_utils
|
||||
type = file_type::DIR;
|
||||
|
||||
auto is_link = std::filesystem::is_symlink(entry);
|
||||
auto is_hidden = file_utils::is_hidden(entry);
|
||||
|
||||
return { entry.path(), type, is_link };
|
||||
return { entry.path(), type, is_link, is_hidden };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,7 +83,7 @@ namespace rrr::file_utils
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
f.push_back({ path / "no permission", file_type::TEXT, false });
|
||||
f.push_back({ path / "no permission", file_type::TEXT, false, false });
|
||||
}
|
||||
|
||||
return f;
|
||||
@@ -109,12 +119,4 @@ namespace rrr::file_utils
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline bool is_hidden(const std::filesystem::path &p)
|
||||
{
|
||||
std::filesystem::path::string_type name = p.filename();
|
||||
if(name != ".." && name != "." && name[0] == '.')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user