mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 05:23:29 -04:00
refactor(entry): use fs namespace alias
This commit is contained in:
parent
6a0ac46293
commit
6288beffb1
@ -43,11 +43,13 @@
|
|||||||
|
|
||||||
namespace dwarfs::internal {
|
namespace dwarfs::internal {
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr std::string_view const kHashContext{"[hashing] "};
|
constexpr std::string_view const kHashContext{"[hashing] "};
|
||||||
constexpr char const kLocalPathSeparator{
|
constexpr char const kLocalPathSeparator{
|
||||||
static_cast<char>(std::filesystem::path::preferred_separator)};
|
static_cast<char>(fs::path::preferred_separator)};
|
||||||
|
|
||||||
bool is_root_path(std::string_view path) {
|
bool is_root_path(std::string_view path) {
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
@ -59,7 +61,7 @@ bool is_root_path(std::string_view path) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
entry::entry(std::filesystem::path const& path, std::shared_ptr<entry> parent,
|
entry::entry(fs::path const& path, std::shared_ptr<entry> parent,
|
||||||
file_stat const& st)
|
file_stat const& st)
|
||||||
: name_{u8string_to_string(parent ? path.filename().u8string()
|
: name_{u8string_to_string(parent ? path.filename().u8string()
|
||||||
: path.u8string())}
|
: path.u8string())}
|
||||||
@ -80,12 +82,12 @@ void entry::set_name(const std::string& name) { name_ = name; }
|
|||||||
|
|
||||||
std::u8string entry::u8name() const { return string_to_u8string(name_); }
|
std::u8string entry::u8name() const { return string_to_u8string(name_); }
|
||||||
|
|
||||||
std::filesystem::path entry::fs_path() const {
|
fs::path entry::fs_path() const {
|
||||||
if (auto parent = parent_.lock()) {
|
if (auto parent = parent_.lock()) {
|
||||||
return parent->fs_path() / u8name();
|
return parent->fs_path() / u8name();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::filesystem::path(u8name());
|
return fs::path(u8name());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string entry::path_as_string() const {
|
std::string entry::path_as_string() const {
|
||||||
@ -436,7 +438,7 @@ void dir::remove_empty_dirs(progress& prog) {
|
|||||||
lookup_.reset();
|
lookup_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<entry> dir::find(std::filesystem::path const& path) {
|
std::shared_ptr<entry> dir::find(fs::path const& path) {
|
||||||
auto name = u8string_to_string(path.filename().u8string());
|
auto name = u8string_to_string(path.filename().u8string());
|
||||||
|
|
||||||
if (!lookup_ && entries_.size() >= 16) {
|
if (!lookup_ && entries_.size() >= 16) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user