| 65 | } |
| 66 | |
| 67 | bool listDirectory( |
| 68 | const std::string& path, |
| 69 | std::function<void(const dirent&)> onEntry |
| 70 | ) { |
| 71 | auto lock = getLock(path)->asScopedLock(); |
| 72 | lock.lock(); |
| 73 | |
| 74 | LOGGER.info("listDir start {}", path); |
| 75 | DIR* dir = opendir(path.c_str()); |
| 76 | if (dir == nullptr) { |
| 77 | LOGGER.error("Failed to open dir {}", path); |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | dirent* current_entry; |
| 82 | while ((current_entry = readdir(dir)) != nullptr) { |
| 83 | onEntry(*current_entry); |
| 84 | } |
| 85 | |
| 86 | closedir(dir); |
| 87 | |
| 88 | LOGGER.info("listDir stop {}", path); |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | int scandir( |
| 93 | const std::string& path, |
no test coverage detected