mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 13:30:47 -04:00
Ensure that input is a directory
This commit is contained in:
parent
0b58eab1e6
commit
0baa67c94b
@ -291,11 +291,21 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
|||||||
log_.info() << "scanning " << path;
|
log_.info() << "scanning " << path;
|
||||||
|
|
||||||
auto root = entry_->create(*os_, path);
|
auto root = entry_->create(*os_, path);
|
||||||
|
|
||||||
|
if (root->type() != entry::E_DIR) {
|
||||||
|
throw std::runtime_error(path + " must be a directory");
|
||||||
|
}
|
||||||
|
|
||||||
std::deque<std::shared_ptr<entry>> queue({root});
|
std::deque<std::shared_ptr<entry>> queue({root});
|
||||||
prog.dirs_found++;
|
prog.dirs_found++;
|
||||||
|
|
||||||
while (!queue.empty()) {
|
while (!queue.empty()) {
|
||||||
auto parent = std::dynamic_pointer_cast<dir>(queue.front());
|
auto parent = std::dynamic_pointer_cast<dir>(queue.front());
|
||||||
|
|
||||||
|
if (!parent) {
|
||||||
|
throw std::runtime_error("expected directory");
|
||||||
|
}
|
||||||
|
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
const std::string& path = parent->path();
|
const std::string& path = parent->path();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user