Debian Codegraph @

yo/coroutines/demo/recursive2/recursivecoro.1

raw
1 Recursive recursiveCoro(string const &directory)
2 {
3 chdir(directory.c_str()); // change to the directory
4
5 while ((entry = nextEntry())) // visit all its entries
6 {
7 string const &name = entry.name();
8 co_yield name; // yield the entry's name
9
10 if (entry.type() == DIRECTORY) // a directory?
11 { // get the full path
12 string path = pathName(directory, name);
13 co_yield path; // yield the full path
14
15 auto rec = recursiveCoro(path); // visit the entries of
16 string next; // the subdir (and of its
17 while (rec.next(&next)) // subdirs)
18 co_yield next; // and yield them
19 }
20 }
21 }