| 363 | } |
| 364 | |
| 365 | Directory getFilesAndDirs(const std::wstring& path) |
| 366 | { |
| 367 | struct Context |
| 368 | { |
| 369 | std::stack<Directory*> current; |
| 370 | }; |
| 371 | |
| 372 | Directory root; |
| 373 | |
| 374 | Context cx; |
| 375 | cx.current.push(&root); |
| 376 | |
| 377 | env::forEachEntry( |
| 378 | path, &cx, |
| 379 | [](void* pcx, std::wstring_view path) { |
| 380 | Context* cx = (Context*)pcx; |
| 381 | |
| 382 | cx->current.top()->dirs.push_back(Directory(path)); |
| 383 | cx->current.push(&cx->current.top()->dirs.back()); |
| 384 | }, |
| 385 | |
| 386 | [](void* pcx, std::wstring_view path) { |
| 387 | Context* cx = (Context*)pcx; |
| 388 | cx->current.pop(); |
| 389 | }, |
| 390 | |
| 391 | [](void* pcx, std::wstring_view path, FILETIME ft, uint64_t s) { |
| 392 | Context* cx = (Context*)pcx; |
| 393 | |
| 394 | cx->current.top()->files.push_back(File(path, ft, s)); |
| 395 | }); |
| 396 | |
| 397 | return root; |
| 398 | } |
| 399 | |
| 400 | File::File(std::wstring_view n, FILETIME ft, uint64_t s) |
| 401 | : name(n.begin(), n.end()), lcname(MOShared::ToLowerCopy(name)), lastModified(ft), |
nothing calls this directly
no test coverage detected