diff --git a/src/dwarfs/scanner.cpp b/src/dwarfs/scanner.cpp index c8d61e7a..d9fd7043 100644 --- a/src/dwarfs/scanner.cpp +++ b/src/dwarfs/scanner.cpp @@ -291,11 +291,21 @@ void scanner_::scan(filesystem_writer& fsw, log_.info() << "scanning " << path; auto root = entry_->create(*os_, path); + + if (root->type() != entry::E_DIR) { + throw std::runtime_error(path + " must be a directory"); + } + std::deque> queue({root}); prog.dirs_found++; while (!queue.empty()) { auto parent = std::dynamic_pointer_cast(queue.front()); + + if (!parent) { + throw std::runtime_error("expected directory"); + } + queue.pop_front(); const std::string& path = parent->path();