re-add directory_entry

master
Daniel Kolesa 2018-04-17 03:02:51 +02:00
parent 77b267a34b
commit 83dc828a89
2 changed files with 38 additions and 10 deletions

View File

@ -895,6 +895,34 @@ private:
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 {
struct OSTD_EXPORT dir_range_impl {
void open(path const &p);
@ -905,7 +933,7 @@ namespace detail {
return p_current.path().empty();
}
file_info const &front() const noexcept {
directory_entry const &front() const noexcept {
return p_current;
}
@ -913,7 +941,7 @@ namespace detail {
close();
}
file_info p_current{};
directory_entry p_current{};
path p_dir{};
void *p_handle = nullptr;
};
@ -929,7 +957,7 @@ namespace detail {
return p_current.path().empty();
}
file_info const &front() const noexcept {
directory_entry const &front() const noexcept {
return p_current;
}
@ -937,7 +965,7 @@ namespace detail {
close();
}
file_info p_current{};
directory_entry p_current{};
path p_dir{};
hstack p_handles{};
};
@ -945,8 +973,8 @@ namespace detail {
struct directory_range: input_range<directory_range> {
using range_category = input_range_tag;
using value_type = file_info;
using reference = file_info const &;
using value_type = directory_entry;
using reference = directory_entry const &;
using size_type = std::size_t;
directory_range() = delete;
@ -974,8 +1002,8 @@ private:
struct recursive_directory_range: input_range<recursive_directory_range> {
using range_category = input_range_tag;
using value_type = file_info;
using reference = file_info const &;
using value_type = directory_entry;
using reference = directory_entry const &;
using size_type = std::size_t;
recursive_directory_range() = delete;

View File

@ -93,7 +93,7 @@ namespace ostd {
namespace fs {
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 *o;
for (;;) {
@ -168,7 +168,7 @@ OSTD_EXPORT void rdir_range_impl::read_next() {
if (!nd) {
abort();
}
file_info based = p_current, curd;
directory_entry based = p_current, curd;
dir_read_next(nd, curd, based);
if (!curd.path().empty()) {
p_dir = based;