77
88namespace odr {
99
10- FileWalker::FileWalker () = default ;
11-
1210FileWalker::FileWalker (std::unique_ptr<internal::abstract::FileWalker> impl)
13- : m_impl{std::move (impl)} {}
11+ : m_impl{std::move (impl)} {
12+ if (m_impl == nullptr ) {
13+ throw std::invalid_argument (" impl must not be null" );
14+ }
15+ }
1416
1517FileWalker::FileWalker (const FileWalker &other)
1618 : m_impl{other.m_impl ->clone ()} {}
@@ -29,71 +31,48 @@ FileWalker &FileWalker::operator=(const FileWalker &other) {
2931
3032FileWalker &FileWalker::operator =(FileWalker &&) noexcept = default ;
3133
32- FileWalker::operator bool () const { return m_impl != nullptr ; }
34+ bool FileWalker::end () const { return m_impl-> end () ; }
3335
34- bool FileWalker::end () const { return m_impl == nullptr || m_impl-> end (); }
36+ std:: uint32_t FileWalker::depth () const { return m_impl-> depth (); }
3537
36- std::uint32_t FileWalker::depth () const {
37- return m_impl != nullptr ? m_impl->depth () : 0 ;
38- }
38+ std::string FileWalker::path () const { return m_impl->path ().string (); }
3939
40- std::string FileWalker::path () const {
41- return m_impl != nullptr ? m_impl->path ().string () : std::string (" " );
42- }
40+ bool FileWalker::is_file () const { return m_impl->is_file (); }
4341
44- bool FileWalker::is_file () const {
45- return m_impl != nullptr && m_impl->is_file ();
46- }
42+ bool FileWalker::is_directory () const { return m_impl->is_directory (); }
4743
48- bool FileWalker::is_directory () const {
49- return m_impl != nullptr && m_impl->is_directory ();
50- }
44+ void FileWalker::pop () const { m_impl->pop (); }
5145
52- void FileWalker::pop () const {
53- if (m_impl != nullptr ) {
54- m_impl->pop ();
55- }
56- }
46+ void FileWalker::next () const { m_impl->next (); }
5747
58- void FileWalker::next () const {
59- if (m_impl != nullptr ) {
60- m_impl->next ();
61- }
62- }
63-
64- void FileWalker::flat_next () const {
65- if (m_impl != nullptr ) {
66- m_impl->flat_next ();
67- }
68- }
48+ void FileWalker::flat_next () const { m_impl->flat_next (); }
6949
7050Filesystem::Filesystem (
7151 std::shared_ptr<internal::abstract::ReadableFilesystem> impl)
72- : m_impl{std::move (impl)} {}
73-
74- Filesystem::operator bool () const { return m_impl != nullptr ; }
52+ : m_impl{std::move (impl)} {
53+ if (m_impl == nullptr ) {
54+ throw std::invalid_argument (" impl must not be null" );
55+ }
56+ }
7557
7658bool Filesystem::exists (const std::string &path) const {
77- return m_impl != nullptr && m_impl ->exists (internal::AbsPath (path));
59+ return m_impl->exists (internal::AbsPath (path));
7860}
7961
8062bool Filesystem::is_file (const std::string &path) const {
81- return m_impl != nullptr && m_impl ->is_file (internal::AbsPath (path));
63+ return m_impl->is_file (internal::AbsPath (path));
8264}
8365
8466bool Filesystem::is_directory (const std::string &path) const {
85- return m_impl != nullptr && m_impl ->is_directory (internal::AbsPath (path));
67+ return m_impl->is_directory (internal::AbsPath (path));
8668}
8769
8870FileWalker Filesystem::file_walker (const std::string &path) const {
89- return m_impl != nullptr
90- ? FileWalker (m_impl->file_walker (internal::AbsPath (path)))
91- : FileWalker ();
71+ return FileWalker (m_impl->file_walker (internal::AbsPath (path)));
9272}
9373
9474File Filesystem::open (const std::string &path) const {
95- return m_impl != nullptr ? File (m_impl->open (internal::AbsPath (path)))
96- : File ();
75+ return File (m_impl->open (internal::AbsPath (path)));
9776}
9877
9978} // namespace odr
0 commit comments