working on directory_only_iterator<filesystem::directory_iterator>
This commit is contained in:
parent
0e0f1cfb7f
commit
6d84be2051
@ -297,15 +297,12 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
std::uintmax_t file_size(const path& p);
|
std::uintmax_t file_size(const path& p);
|
||||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
inline bool is_directory(file_status s) { return s.type() == file_type::directory ;}
|
inline bool is_directory(file_status s) noexcept
|
||||||
bool is_directory(const path& p);
|
{ return s.type() == file_type::directory ;}
|
||||||
inline bool is_directory(const directory_entry& d)
|
|
||||||
{
|
|
||||||
return is_directory(d.status());
|
|
||||||
}
|
|
||||||
//bool is_directory(const path& p, error_code& ec) noexcept;
|
|
||||||
|
|
||||||
//bool is_regular_file(file_status s) noexcept;
|
bool is_directory(const path& p);
|
||||||
|
|
||||||
|
//bool is_directory(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
inline bool is_empty(const path& p)
|
inline bool is_empty(const path& p)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,18 +26,56 @@ namespace nana {namespace experimental {namespace filesystem {namespace ext {
|
|||||||
constexpr auto def_rootname = "Root/";
|
constexpr auto def_rootname = "Root/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// nana::experimental::filesystem::path_user()); // REPLACE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! to filesystem_ext.hhp
|
// nana::experimental::filesystem::path_user()); // REPLACE !!!!!!!!!! to filesystem_ext.hhp
|
||||||
|
|
||||||
template<class DI> // DI = directory_iterator from std, boost, or nana
|
inline bool is_directory(const directory_entry& d) noexcept
|
||||||
|
{
|
||||||
|
return is_directory(d.status());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
|
||||||
class directory_only_iterator : public DI
|
class directory_only_iterator : public DI
|
||||||
{
|
{
|
||||||
// if (!this->is_directory()) continue;
|
DI& find_first()
|
||||||
|
{
|
||||||
|
while(( (*this) != DI{}) || !is_directory((*this)) )
|
||||||
|
this->DI::operator++();
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
template <class... Arg>
|
||||||
|
directory_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
|
||||||
|
{
|
||||||
|
find_first();
|
||||||
|
}
|
||||||
|
directory_only_iterator& operator++()
|
||||||
|
{
|
||||||
|
this->DI::operator++();
|
||||||
|
return find_first();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class DI> // DI = directory_iterator from std, boost, or nana
|
template<class DI> // DI = directory_iterator from std, boost, or nana : value_type directory_entry
|
||||||
class regular_file_only_iterator : public DI
|
class regular_file_only_iterator : public DI
|
||||||
{
|
{
|
||||||
// if (this->is_directory()) continue;
|
DI& find_first()
|
||||||
|
{
|
||||||
|
while(( (*this) != DI{}) || !is_regular_file(*this) )
|
||||||
|
this->DI::operator++();
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
template <class... Arg>
|
||||||
|
regular_file_only_iterator(Arg&&... arg ): DI(std::forward<Arg>(arg)...)
|
||||||
|
{
|
||||||
|
find_first();
|
||||||
|
}
|
||||||
|
regular_file_only_iterator& operator++()
|
||||||
|
{
|
||||||
|
this->DI::operator++();
|
||||||
|
return find_first();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}}}}
|
}}}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user