123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628 |
- // boost/filesystem/directory.hpp ---------------------------------------------------//
- // Copyright Beman Dawes 2002-2009
- // Copyright Jan Langer 2002
- // Copyright Dietmar Kuehl 2001
- // Copyright Vladimir Prus 2002
- // Copyright Andrey Semashev 2019
- // Distributed under the Boost Software License, Version 1.0.
- // See http://www.boost.org/LICENSE_1_0.txt
- // Library home page: http://www.boost.org/libs/filesystem
- //--------------------------------------------------------------------------------------//
- #ifndef BOOST_FILESYSTEM3_DIRECTORY_HPP
- #define BOOST_FILESYSTEM3_DIRECTORY_HPP
- #include <boost/config.hpp>
- # if defined( BOOST_NO_STD_WSTRING )
- # error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
- # endif
- #include <boost/filesystem/config.hpp>
- #include <boost/filesystem/path.hpp>
- #include <boost/filesystem/file_status.hpp>
- #include <string>
- #include <vector>
- #include <utility> // std::move
- #include <boost/assert.hpp>
- #include <boost/core/scoped_enum.hpp>
- #include <boost/detail/bitmask.hpp>
- #include <boost/system/error_code.hpp>
- #include <boost/smart_ptr/intrusive_ptr.hpp>
- #include <boost/smart_ptr/intrusive_ref_counter.hpp>
- #include <boost/iterator/iterator_facade.hpp>
- #include <boost/iterator/iterator_categories.hpp>
- #include <boost/config/abi_prefix.hpp> // must be the last #include
- //--------------------------------------------------------------------------------------//
- namespace boost {
- namespace filesystem {
- //--------------------------------------------------------------------------------------//
- // //
- // directory_entry //
- // //
- //--------------------------------------------------------------------------------------//
- // GCC has a problem with a member function named path within a namespace or
- // sub-namespace that also has a class named path. The workaround is to always
- // fully qualify the name path when it refers to the class name.
- class directory_entry
- {
- public:
- typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry
- directory_entry() BOOST_NOEXCEPT {}
- explicit directory_entry(const boost::filesystem::path& p) :
- m_path(p), m_status(file_status()), m_symlink_status(file_status())
- {
- }
- directory_entry(const boost::filesystem::path& p,
- file_status st, file_status symlink_st = file_status()) :
- m_path(p), m_status(st), m_symlink_status(symlink_st)
- {
- }
- directory_entry(const directory_entry& rhs) :
- m_path(rhs.m_path), m_status(rhs.m_status), m_symlink_status(rhs.m_symlink_status)
- {
- }
- directory_entry& operator=(const directory_entry& rhs)
- {
- m_path = rhs.m_path;
- m_status = rhs.m_status;
- m_symlink_status = rhs.m_symlink_status;
- return *this;
- }
- // As of October 2015 the interaction between noexcept and =default is so troublesome
- // for VC++, GCC, and probably other compilers, that =default is not used with noexcept
- // functions. GCC is not even consistent for the same release on different platforms.
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- directory_entry(directory_entry&& rhs) BOOST_NOEXCEPT :
- m_path(std::move(rhs.m_path)), m_status(std::move(rhs.m_status)), m_symlink_status(std::move(rhs.m_symlink_status))
- {
- }
- directory_entry& operator=(directory_entry&& rhs) BOOST_NOEXCEPT
- {
- m_path = std::move(rhs.m_path);
- m_status = std::move(rhs.m_status);
- m_symlink_status = std::move(rhs.m_symlink_status);
- return *this;
- }
- #endif
- void assign(const boost::filesystem::path& p,
- file_status st = file_status(), file_status symlink_st = file_status())
- {
- m_path = p;
- m_status = st;
- m_symlink_status = symlink_st;
- }
- void replace_filename(const boost::filesystem::path& p,
- file_status st = file_status(), file_status symlink_st = file_status())
- {
- m_path.remove_filename();
- m_path /= p;
- m_status = st;
- m_symlink_status = symlink_st;
- }
- # ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- void replace_leaf(const boost::filesystem::path& p, file_status st, file_status symlink_st)
- {
- replace_filename(p, st, symlink_st);
- }
- # endif
- const boost::filesystem::path& path() const BOOST_NOEXCEPT { return m_path; }
- operator const boost::filesystem::path&() const BOOST_NOEXCEPT { return m_path; }
- file_status status() const { return get_status(); }
- file_status status(system::error_code& ec) const BOOST_NOEXCEPT { return get_status(&ec); }
- file_status symlink_status() const { return get_symlink_status(); }
- file_status symlink_status(system::error_code& ec) const BOOST_NOEXCEPT { return get_symlink_status(&ec); }
- bool operator==(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path == rhs.m_path; }
- bool operator!=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path != rhs.m_path; }
- bool operator< (const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path < rhs.m_path; }
- bool operator<=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path <= rhs.m_path; }
- bool operator> (const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path > rhs.m_path; }
- bool operator>=(const directory_entry& rhs) const BOOST_NOEXCEPT { return m_path >= rhs.m_path; }
- private:
- BOOST_FILESYSTEM_DECL file_status get_status(system::error_code* ec=0) const;
- BOOST_FILESYSTEM_DECL file_status get_symlink_status(system::error_code* ec=0) const;
- private:
- boost::filesystem::path m_path;
- mutable file_status m_status; // stat()-like
- mutable file_status m_symlink_status; // lstat()-like
- }; // directory_entry
- //--------------------------------------------------------------------------------------//
- // //
- // directory_entry overloads //
- // //
- //--------------------------------------------------------------------------------------//
- // Without these functions, calling (for example) 'is_directory' with a 'directory_entry' results in:
- // - a conversion to 'path' using 'operator const boost::filesystem::path&()',
- // - then a call to 'is_directory(const path& p)' which recomputes the status with 'detail::status(p)'.
- //
- // These functions avoid a costly recomputation of the status if one calls 'is_directory(e)' instead of 'is_directory(e.status())'
- inline file_status status (const directory_entry& e) { return e.status(); }
- inline file_status status (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return e.status(ec); }
- inline bool type_present (const directory_entry& e) { return filesystem::type_present(e.status()); }
- inline bool type_present (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::type_present(e.status(ec)); }
- inline bool status_known (const directory_entry& e) { return filesystem::status_known(e.status()); }
- inline bool status_known (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::status_known(e.status(ec)); }
- inline bool exists (const directory_entry& e) { return filesystem::exists(e.status()); }
- inline bool exists (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::exists(e.status(ec)); }
- inline bool is_regular_file(const directory_entry& e) { return filesystem::is_regular_file(e.status()); }
- inline bool is_regular_file(const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_regular_file(e.status(ec)); }
- inline bool is_directory (const directory_entry& e) { return filesystem::is_directory(e.status()); }
- inline bool is_directory (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_directory(e.status(ec)); }
- inline bool is_symlink (const directory_entry& e) { return filesystem::is_symlink(e.symlink_status()); }
- inline bool is_symlink (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_symlink(e.symlink_status(ec)); }
- inline bool is_other (const directory_entry& e) { return filesystem::is_other(e.status()); }
- inline bool is_other (const directory_entry& e, system::error_code& ec) BOOST_NOEXCEPT { return filesystem::is_other(e.status(ec)); }
- #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- inline bool is_regular (const directory_entry& e) { return filesystem::is_regular(e.status()); }
- #endif
- //--------------------------------------------------------------------------------------//
- // //
- // directory_iterator helpers //
- // //
- //--------------------------------------------------------------------------------------//
- BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(directory_options, unsigned int)
- {
- none = 0u,
- skip_permission_denied = 1u, // if a directory cannot be opened because of insufficient permissions, pretend that the directory is empty
- follow_directory_symlink = 1u << 1, // recursive_directory_iterator: follow directory symlinks
- skip_dangling_symlinks = 1u << 2, // non-standard extension for recursive_directory_iterator: don't follow dangling directory symlinks,
- pop_on_error = 1u << 3, // non-standard extension for recursive_directory_iterator: instead of producing an end iterator on errors,
- // repeatedly invoke pop() until it succeeds or the iterator becomes equal to end iterator
- _detail_no_push = 1u << 4 // internal use only
- }
- BOOST_SCOPED_ENUM_DECLARE_END(directory_options)
- BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(directory_options))
- class directory_iterator;
- namespace detail {
- BOOST_FILESYSTEM_DECL
- system::error_code dir_itr_close(// never throws()
- void*& handle
- #if defined(BOOST_POSIX_API)
- , void*& buffer
- #endif
- ) BOOST_NOEXCEPT;
- struct dir_itr_imp :
- public boost::intrusive_ref_counter< dir_itr_imp >
- {
- directory_entry dir_entry;
- void* handle;
- #if defined(BOOST_POSIX_API)
- void* buffer; // see dir_itr_increment implementation
- #endif
- dir_itr_imp() BOOST_NOEXCEPT :
- handle(0)
- #if defined(BOOST_POSIX_API)
- , buffer(0)
- #endif
- {
- }
- ~dir_itr_imp() BOOST_NOEXCEPT
- {
- dir_itr_close(handle
- #if defined(BOOST_POSIX_API)
- , buffer
- #endif
- );
- }
- };
- // see path::iterator: comment below
- BOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it, const path& p, unsigned int opts, system::error_code* ec);
- BOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it, system::error_code* ec);
- } // namespace detail
- //--------------------------------------------------------------------------------------//
- // //
- // directory_iterator //
- // //
- //--------------------------------------------------------------------------------------//
- class directory_iterator :
- public boost::iterator_facade<
- directory_iterator,
- directory_entry,
- boost::single_pass_traversal_tag
- >
- {
- friend class boost::iterator_core_access;
- friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it, const path& p, unsigned int opts, system::error_code* ec);
- friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it, system::error_code* ec);
- public:
- directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator
- // iterator_facade derived classes don't seem to like implementations in
- // separate translation unit dll's, so forward to detail functions
- explicit directory_iterator(const path& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts = directory_options::none)
- {
- detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), 0);
- }
- directory_iterator(const path& p, system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(directory_options::none), &ec);
- }
- directory_iterator(const path& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), &ec);
- }
- BOOST_DEFAULTED_FUNCTION(directory_iterator(directory_iterator const& that), : m_imp(that.m_imp) {})
- BOOST_DEFAULTED_FUNCTION(directory_iterator& operator= (directory_iterator const& that), { m_imp = that.m_imp; return *this; })
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- directory_iterator(directory_iterator&& that) BOOST_NOEXCEPT :
- m_imp(std::move(that.m_imp))
- {
- }
- directory_iterator& operator= (directory_iterator&& that) BOOST_NOEXCEPT
- {
- m_imp = std::move(that.m_imp);
- return *this;
- }
- #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::directory_iterator_increment(*this, &ec);
- return *this;
- }
- private:
- boost::iterator_facade<
- directory_iterator,
- directory_entry,
- boost::single_pass_traversal_tag
- >::reference dereference() const
- {
- BOOST_ASSERT_MSG(!is_end(), "attempt to dereference end directory iterator");
- return m_imp->dir_entry;
- }
- void increment() { detail::directory_iterator_increment(*this, 0); }
- bool equal(const directory_iterator& rhs) const BOOST_NOEXCEPT
- {
- return m_imp == rhs.m_imp || (is_end() && rhs.is_end());
- }
- bool is_end() const BOOST_NOEXCEPT
- {
- // Note: The check for handle is needed because the iterator can be copied and the copy
- // can be incremented to end while the original iterator still refers to the same dir_itr_imp.
- return !m_imp || !m_imp->handle;
- }
- private:
- // intrusive_ptr provides the shallow-copy semantics required for single pass iterators
- // (i.e. InputIterators). The end iterator is indicated by is_end().
- boost::intrusive_ptr< detail::dir_itr_imp > m_imp;
- };
- // enable directory_iterator C++11 range-based for statement use --------------------//
- // begin() and end() are only used by a range-based for statement in the context of
- // auto - thus the top-level const is stripped - so returning const is harmless and
- // emphasizes begin() is just a pass through.
- inline const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
- // enable C++14 generic accessors for range const iterators
- inline const directory_iterator& cbegin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline directory_iterator cend(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
- // enable directory_iterator BOOST_FOREACH -----------------------------------------//
- inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline directory_iterator range_begin(const directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
- inline directory_iterator range_end(const directory_iterator&) BOOST_NOEXCEPT { return directory_iterator(); }
- } // namespace filesystem
- // namespace boost template specializations
- template<typename C, typename Enabler>
- struct range_mutable_iterator;
- template<>
- struct range_mutable_iterator<boost::filesystem::directory_iterator, void>
- {
- typedef boost::filesystem::directory_iterator type;
- };
- template<typename C, typename Enabler>
- struct range_const_iterator;
- template<>
- struct range_const_iterator<boost::filesystem::directory_iterator, void>
- {
- typedef boost::filesystem::directory_iterator type;
- };
- namespace filesystem {
- //--------------------------------------------------------------------------------------//
- // //
- // recursive_directory_iterator helpers //
- // //
- //--------------------------------------------------------------------------------------//
- #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
- // Deprecated enum, use directory_options instead
- BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(symlink_option, unsigned int)
- {
- none = static_cast< unsigned int >(directory_options::none),
- no_recurse = none, // don't follow directory symlinks (default behavior)
- recurse = static_cast< unsigned int >(directory_options::follow_directory_symlink), // follow directory symlinks
- _detail_no_push = static_cast< unsigned int >(directory_options::_detail_no_push) // internal use only
- }
- BOOST_SCOPED_ENUM_DECLARE_END(symlink_option)
- BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(symlink_option))
- #endif // BOOST_FILESYSTEM_NO_DEPRECATED
- class recursive_directory_iterator;
- namespace detail {
- struct recur_dir_itr_imp :
- public boost::intrusive_ref_counter< recur_dir_itr_imp >
- {
- typedef directory_iterator element_type;
- std::vector< element_type > m_stack;
- // directory_options values, declared as unsigned int for ABI compatibility
- unsigned int m_options;
- explicit recur_dir_itr_imp(unsigned int opts) BOOST_NOEXCEPT : m_options(opts) {}
- };
- BOOST_FILESYSTEM_DECL void recursive_directory_iterator_construct(recursive_directory_iterator& it, const path& dir_path, unsigned int opts, system::error_code* ec);
- BOOST_FILESYSTEM_DECL void recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
- BOOST_FILESYSTEM_DECL void recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
- } // namespace detail
- //--------------------------------------------------------------------------------------//
- // //
- // recursive_directory_iterator //
- // //
- //--------------------------------------------------------------------------------------//
- class recursive_directory_iterator :
- public boost::iterator_facade<
- recursive_directory_iterator,
- directory_entry,
- boost::single_pass_traversal_tag
- >
- {
- friend class boost::iterator_core_access;
- friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_construct(recursive_directory_iterator& it, const path& dir_path, unsigned int opts, system::error_code* ec);
- friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
- friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
- public:
- recursive_directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator
- explicit recursive_directory_iterator(const path& dir_path)
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), 0);
- }
- recursive_directory_iterator(const path& dir_path, system::error_code& ec)
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), &ec);
- }
- recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts)
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
- }
- recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec)
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
- }
- #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
- // Deprecated constructors
- recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts)
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
- }
- recursive_directory_iterator(const path& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts, system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
- }
- #endif // BOOST_FILESYSTEM_NO_DEPRECATED
- BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator(recursive_directory_iterator const& that), : m_imp(that.m_imp) {})
- BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator& operator= (recursive_directory_iterator const& that), { m_imp = that.m_imp; return *this; })
- #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- recursive_directory_iterator(recursive_directory_iterator&& that) BOOST_NOEXCEPT :
- m_imp(std::move(that.m_imp))
- {
- }
- recursive_directory_iterator& operator= (recursive_directory_iterator&& that) BOOST_NOEXCEPT
- {
- m_imp = std::move(that.m_imp);
- return *this;
- }
- #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- recursive_directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::recursive_directory_iterator_increment(*this, &ec);
- return *this;
- }
- int depth() const BOOST_NOEXCEPT
- {
- BOOST_ASSERT_MSG(!is_end(), "depth() on end recursive_directory_iterator");
- return static_cast< int >(m_imp->m_stack.size() - 1u);
- }
- bool recursion_pending() const BOOST_NOEXCEPT
- {
- BOOST_ASSERT_MSG(!is_end(), "recursion_pending() on end recursive_directory_iterator");
- return (m_imp->m_options & static_cast< unsigned int >(directory_options::_detail_no_push)) == 0u;
- }
- #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- int level() const BOOST_NOEXCEPT { return depth(); }
- bool no_push_pending() const BOOST_NOEXCEPT { return !recursion_pending(); }
- bool no_push_request() const BOOST_NOEXCEPT { return !recursion_pending(); }
- #endif
- void pop()
- {
- detail::recursive_directory_iterator_pop(*this, 0);
- }
- void pop(system::error_code& ec) BOOST_NOEXCEPT
- {
- detail::recursive_directory_iterator_pop(*this, &ec);
- }
- void disable_recursion_pending(bool value = true) BOOST_NOEXCEPT
- {
- BOOST_ASSERT_MSG(!is_end(), "disable_recursion_pending() on end recursive_directory_iterator");
- if (value)
- m_imp->m_options |= static_cast< unsigned int >(directory_options::_detail_no_push);
- else
- m_imp->m_options &= ~static_cast< unsigned int >(directory_options::_detail_no_push);
- }
- #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- void no_push(bool value = true) BOOST_NOEXCEPT { disable_recursion_pending(value); }
- #endif
- file_status status() const
- {
- BOOST_ASSERT_MSG(!is_end(), "status() on end recursive_directory_iterator");
- return m_imp->m_stack.back()->status();
- }
- file_status symlink_status() const
- {
- BOOST_ASSERT_MSG(!is_end(), "symlink_status() on end recursive_directory_iterator");
- return m_imp->m_stack.back()->symlink_status();
- }
- private:
- boost::iterator_facade<
- recursive_directory_iterator,
- directory_entry,
- boost::single_pass_traversal_tag
- >::reference dereference() const
- {
- BOOST_ASSERT_MSG(!is_end(), "dereference of end recursive_directory_iterator");
- return *m_imp->m_stack.back();
- }
- void increment() { detail::recursive_directory_iterator_increment(*this, 0); }
- bool equal(const recursive_directory_iterator& rhs) const BOOST_NOEXCEPT
- {
- return m_imp == rhs.m_imp || (is_end() && rhs.is_end());
- }
- bool is_end() const BOOST_NOEXCEPT
- {
- // Note: The check for m_stack.empty() is needed because the iterator can be copied and the copy
- // can be incremented to end while the original iterator still refers to the same recur_dir_itr_imp.
- return !m_imp || m_imp->m_stack.empty();
- }
- private:
- // intrusive_ptr provides the shallow-copy semantics required for single pass iterators
- // (i.e. InputIterators). The end iterator is indicated by is_end().
- boost::intrusive_ptr< detail::recur_dir_itr_imp > m_imp;
- };
- #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
- typedef recursive_directory_iterator wrecursive_directory_iterator;
- #endif
- // enable recursive directory iterator C++11 range-base for statement use ----------//
- // begin() and end() are only used by a range-based for statement in the context of
- // auto - thus the top-level const is stripped - so returning const is harmless and
- // emphasizes begin() is just a pass through.
- inline const recursive_directory_iterator& begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline recursive_directory_iterator end(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
- // enable C++14 generic accessors for range const iterators
- inline const recursive_directory_iterator& cbegin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline recursive_directory_iterator cend(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
- // enable recursive directory iterator BOOST_FOREACH -------------------------------//
- inline recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline recursive_directory_iterator range_begin(const recursive_directory_iterator& iter) BOOST_NOEXCEPT { return iter; }
- inline recursive_directory_iterator range_end(recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
- inline recursive_directory_iterator range_end(const recursive_directory_iterator&) BOOST_NOEXCEPT { return recursive_directory_iterator(); }
- } // namespace filesystem
- // namespace boost template specializations
- template<>
- struct range_mutable_iterator<boost::filesystem::recursive_directory_iterator, void>
- {
- typedef boost::filesystem::recursive_directory_iterator type;
- };
- template<>
- struct range_const_iterator<boost::filesystem::recursive_directory_iterator, void>
- {
- typedef boost::filesystem::recursive_directory_iterator type;
- };
- } // namespace boost
- #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
- #endif // BOOST_FILESYSTEM3_DIRECTORY_HPP
|