| 45 | } |
| 46 | |
| 47 | std::vector<std::string> readdir(const char* dname) { |
| 48 | static std::vector<std::string> skip( |
| 49 | {".", "..", "dev", "tmp", "home", "proc"}); |
| 50 | printf("Files in '%s': ", dname); |
| 51 | std::vector<std::string> files; |
| 52 | DIR* d = opendir(dname); |
| 53 | if (d) { |
| 54 | struct dirent* dir; |
| 55 | while ((dir = readdir(d)) != NULL) { |
| 56 | if (dir->d_type & (DT_DIR | DT_REG)) { |
| 57 | if (std::find(skip.begin(), skip.end(), dir->d_name) == skip.end()) { |
| 58 | files.emplace_back(dir->d_name); |
| 59 | printf("%s ", dir->d_name); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | closedir(d); |
| 64 | } |
| 65 | printf("\n"); |
| 66 | return files; |
| 67 | } |
| 68 | |
| 69 | int main() { |
| 70 | // Create a file. |
no test coverage detected