| 260 | } |
| 261 | |
| 262 | void KittyIOFile::listFilesCallback(const std::string &dirPath, std::function<bool(const std::string &)> cb) |
| 263 | { |
| 264 | DIR *dir = opendir(dirPath.c_str()); |
| 265 | if (!dir) |
| 266 | return; |
| 267 | |
| 268 | std::string base = dirPath; |
| 269 | if (!base.empty() && base.back() != '/') |
| 270 | base += '/'; |
| 271 | |
| 272 | while (struct dirent *f = readdir(dir)) |
| 273 | { |
| 274 | if (f->d_name[0] == '.') |
| 275 | continue; |
| 276 | |
| 277 | std::string path = base + f->d_name; |
| 278 | if (f->d_type == DT_DIR) |
| 279 | { |
| 280 | listFilesCallback(path, cb); |
| 281 | } |
| 282 | else if (f->d_type == DT_REG) |
| 283 | { |
| 284 | if (cb && cb(path)) |
| 285 | break; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | closedir(dir); |
| 290 | } |
| 291 | |
| 292 | bool KittyIOFile::createDirectoryRecursive(const std::string &path, mode_t mode) |
| 293 | { |
nothing calls this directly
no outgoing calls
no test coverage detected