| 54 | |
| 55 | |
| 56 | EMSCRIPTEN_KEEPALIVE |
| 57 | char *FileList_getFileNameString(const char *directoryPath, size_t fileNumber) |
| 58 | { |
| 59 | if (fileNumber >= FileList_getFileCount(directoryPath)) { |
| 60 | |
| 61 | printf("ERROR: illegal file index"); |
| 62 | return 0; |
| 63 | } |
| 64 | else { |
| 65 | |
| 66 | struct dirent *directoryEntry; |
| 67 | DIR *directory = opendir(directoryPath); |
| 68 | if (directory) { |
| 69 | |
| 70 | size_t currentIndex = 0; |
| 71 | while ((directoryEntry = readdir(directory)) != NULL) { |
| 72 | |
| 73 | struct stat st; |
| 74 | lstat(directoryEntry->d_name, &st); |
| 75 | |
| 76 | if (S_ISDIR(st.st_mode)) { |
| 77 | |
| 78 | continue; |
| 79 | } |
| 80 | else { |
| 81 | if (currentIndex == fileNumber) { |
| 82 | |
| 83 | closedir(directory); |
| 84 | return directoryEntry->d_name; |
| 85 | } |
| 86 | |
| 87 | currentIndex++; |
| 88 | } |
| 89 | |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | } |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 |
nothing calls this directly
no test coverage detected