re-add directory_entry
parent
77b267a34b
commit
83dc828a89
44
ostd/path.hh
44
ostd/path.hh
|
@ -895,6 +895,34 @@ private:
|
||||||
ostd::path p_path{};
|
ostd::path p_path{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct directory_entry {
|
||||||
|
directory_entry() {}
|
||||||
|
directory_entry(ostd::path const &p): p_path(p) {}
|
||||||
|
|
||||||
|
ostd::path const &path() const noexcept {
|
||||||
|
return p_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator ostd::path const &() const noexcept {
|
||||||
|
return p_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
p_path.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign(ostd::path const &p) {
|
||||||
|
p_path = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign(ostd::path &&p) {
|
||||||
|
p_path = std::move(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ostd::path p_path{};
|
||||||
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct OSTD_EXPORT dir_range_impl {
|
struct OSTD_EXPORT dir_range_impl {
|
||||||
void open(path const &p);
|
void open(path const &p);
|
||||||
|
@ -905,7 +933,7 @@ namespace detail {
|
||||||
return p_current.path().empty();
|
return p_current.path().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info const &front() const noexcept {
|
directory_entry const &front() const noexcept {
|
||||||
return p_current;
|
return p_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,7 +941,7 @@ namespace detail {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info p_current{};
|
directory_entry p_current{};
|
||||||
path p_dir{};
|
path p_dir{};
|
||||||
void *p_handle = nullptr;
|
void *p_handle = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -929,7 +957,7 @@ namespace detail {
|
||||||
return p_current.path().empty();
|
return p_current.path().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info const &front() const noexcept {
|
directory_entry const &front() const noexcept {
|
||||||
return p_current;
|
return p_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,7 +965,7 @@ namespace detail {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_info p_current{};
|
directory_entry p_current{};
|
||||||
path p_dir{};
|
path p_dir{};
|
||||||
hstack p_handles{};
|
hstack p_handles{};
|
||||||
};
|
};
|
||||||
|
@ -945,8 +973,8 @@ namespace detail {
|
||||||
|
|
||||||
struct directory_range: input_range<directory_range> {
|
struct directory_range: input_range<directory_range> {
|
||||||
using range_category = input_range_tag;
|
using range_category = input_range_tag;
|
||||||
using value_type = file_info;
|
using value_type = directory_entry;
|
||||||
using reference = file_info const &;
|
using reference = directory_entry const &;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
|
|
||||||
directory_range() = delete;
|
directory_range() = delete;
|
||||||
|
@ -974,8 +1002,8 @@ private:
|
||||||
|
|
||||||
struct recursive_directory_range: input_range<recursive_directory_range> {
|
struct recursive_directory_range: input_range<recursive_directory_range> {
|
||||||
using range_category = input_range_tag;
|
using range_category = input_range_tag;
|
||||||
using value_type = file_info;
|
using value_type = directory_entry;
|
||||||
using reference = file_info const &;
|
using reference = directory_entry const &;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
|
|
||||||
recursive_directory_range() = delete;
|
recursive_directory_range() = delete;
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace ostd {
|
||||||
namespace fs {
|
namespace fs {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
static void dir_read_next(DIR *dh, file_info &cur, path const &base) {
|
static void dir_read_next(DIR *dh, directory_entry &cur, path const &base) {
|
||||||
struct dirent d;
|
struct dirent d;
|
||||||
struct dirent *o;
|
struct dirent *o;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -168,7 +168,7 @@ OSTD_EXPORT void rdir_range_impl::read_next() {
|
||||||
if (!nd) {
|
if (!nd) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
file_info based = p_current, curd;
|
directory_entry based = p_current, curd;
|
||||||
dir_read_next(nd, curd, based);
|
dir_read_next(nd, curd, based);
|
||||||
if (!curd.path().empty()) {
|
if (!curd.path().empty()) {
|
||||||
p_dir = based;
|
p_dir = based;
|
||||||
|
|
Loading…
Reference in New Issue