MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / readdir

Function readdir

test/other/test_fs_icase.cpp:47–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47std::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
69int main() {
70 // Create a file.

Callers 12

mainFunction · 0.70
lsFunction · 0.70
mainFunction · 0.70
mainFunction · 0.70
testFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
test_directory_absFunction · 0.50
mainFunction · 0.50
test_readdirFunction · 0.50
list_dirFunction · 0.50
mainFunction · 0.50

Calls 7

printfFunction · 0.85
opendirFunction · 0.85
closedirFunction · 0.85
emplace_backMethod · 0.80
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected