| 25 | #include <emscripten.h> |
| 26 | |
| 27 | EMSCRIPTEN_KEEPALIVE |
| 28 | size_t FileList_getFileCount(const char *directoryPath) |
| 29 | { |
| 30 | struct dirent *directoryEntry; |
| 31 | DIR *directory = opendir(directoryPath); |
| 32 | size_t fileCount = 0; |
| 33 | if (directory) { |
| 34 | |
| 35 | while ((directoryEntry = readdir(directory)) != NULL) { |
| 36 | |
| 37 | struct stat st; |
| 38 | lstat(directoryEntry->d_name, &st); |
| 39 | |
| 40 | if (S_ISDIR(st.st_mode)) { |
| 41 | |
| 42 | continue; |
| 43 | } |
| 44 | else { |
| 45 | fileCount++; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | closedir(directory); |
| 50 | } |
| 51 | |
| 52 | return fileCount; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | EMSCRIPTEN_KEEPALIVE |
no test coverage detected