| 116 | } |
| 117 | |
| 118 | int menuFileAssocScan(const char* target) |
| 119 | { |
| 120 | menuFileAssocClear(); |
| 121 | |
| 122 | if (chdir(target) < 0) |
| 123 | return 1; |
| 124 | |
| 125 | if (getcwd(s_menuFileAssoc[!s_curMenuFileAssoc].dirname, PATH_MAX + 1) == NULL) |
| 126 | return 1; |
| 127 | |
| 128 | DIR* dir; |
| 129 | struct dirent* dp; |
| 130 | char temp[PATH_MAX + 1]; |
| 131 | |
| 132 | dir = opendir(s_menuFileAssoc[!s_curMenuFileAssoc].dirname); |
| 133 | if (!dir) |
| 134 | return 2; |
| 135 | |
| 136 | while ((dp = readdir(dir))) { |
| 137 | if (dp->d_name[0] == '.') |
| 138 | continue; |
| 139 | |
| 140 | memset(temp, 0, sizeof(temp)); |
| 141 | snprintf(temp, sizeof(temp) - 1, "%s/%s", s_menuFileAssoc[!s_curMenuFileAssoc].dirname, dp->d_name); |
| 142 | |
| 143 | const char* ext = getExtension(dp->d_name); |
| 144 | if (strcasecmp(ext, ".cfg") != 0) |
| 145 | continue; |
| 146 | |
| 147 | menuEntryFileAssocLoad(temp); |
| 148 | } |
| 149 | |
| 150 | closedir(dir); |
| 151 | s_curMenuFileAssoc = !s_curMenuFileAssoc; |
| 152 | menuFileAssocClear(); |
| 153 | |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | int menuScan(const char* target) |
| 158 | { |
no test coverage detected