1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-08-17 15:19:48 +00:00

Implement hash_dir() using DirIterator. WiP

Keep the old implementation as well, so they can be easily tested.
Uncomment the USE_LEGACY_HASH_DIR define at the top to build with the
old function.
This commit is contained in:
King_DuckZ 2016-02-16 20:29:50 +01:00
parent 0a3e469951
commit 5908828390
2 changed files with 126 additions and 0 deletions

View file

@ -34,6 +34,11 @@ namespace mchlib {
template <bool Const> class SetListingView;
template <bool Const> const PathName& get_pathname ( const implem::DirIterator<Const>& parIter );
template <bool Const>
implem::DirIterator<Const> first_file ( const SetListingView<Const>& parList );
template <bool Const>
implem::DirIterator<Const> first_file ( SetListingView<Const>& parList );
namespace implem {
template <bool Const>
class DirIterator : public boost::iterator_facade<DirIterator<Const>, FileRecordData, boost::forward_traversal_tag> {
@ -126,6 +131,26 @@ namespace mchlib {
inline const PathName& get_pathname (const implem::DirIterator<Const>& parIter) {
return *parIter.m_base_path;
}
template <bool Const>
inline implem::DirIterator<Const> first_file (const SetListingView<Const>& parList) {
auto end = parList.end();
for (auto it = parList.begin(); it != end; ++it) {
if (not it->is_directory)
return std::move(it);
}
return parList.end();
}
template <bool Const>
inline implem::DirIterator<Const> first_file (SetListingView<Const>& parList) {
auto end = parList.end();
for (auto it = parList.begin(); it != end; ++it) {
if (not it->is_directory)
return std::move(it);
}
return parList.end();
}
} //namespace mchlib
#endif