| 155 | } |
| 156 | |
| 157 | int menuScan(const char* target) |
| 158 | { |
| 159 | if (chdir(target) < 0) return 1; |
| 160 | getcwd(s_menu[!s_curMenu].dirname, PATH_MAX+1); |
| 161 | |
| 162 | DIR* dir; |
| 163 | struct dirent* dp; |
| 164 | dir = opendir(s_menu[!s_curMenu].dirname); |
| 165 | if (!dir) return 2; |
| 166 | |
| 167 | while ((dp = readdir(dir))) |
| 168 | { |
| 169 | archive_dir_t* dirSt = (archive_dir_t*)dir->dirData->dirStruct; |
| 170 | FS_DirectoryEntry* entry = &dirSt->entry_data[dirSt->index]; |
| 171 | menuEntry_s* me = NULL; |
| 172 | bool shortcut = false; |
| 173 | if (entry->attributes & FS_ATTRIBUTE_HIDDEN || dp->d_name[0] == '.') |
| 174 | continue; |
| 175 | |
| 176 | if (entry->attributes & FS_ATTRIBUTE_DIRECTORY) |
| 177 | me = menuCreateEntry(ENTRY_TYPE_FOLDER); |
| 178 | else |
| 179 | { |
| 180 | const char* ext = getExtension(dp->d_name); |
| 181 | if (strcasecmp(ext, ".3dsx")==0 || (shortcut = strcasecmp(ext, ".xml")==0)) |
| 182 | me = menuCreateEntry(ENTRY_TYPE_FILE); |
| 183 | |
| 184 | if (!me) |
| 185 | me = menuCreateEntry(ENTRY_TYPE_FILE_OTHER); |
| 186 | } |
| 187 | |
| 188 | if (!me) |
| 189 | continue; |
| 190 | |
| 191 | snprintf(me->path, sizeof(me->path), "%s/%s", s_menu[!s_curMenu].dirname, dp->d_name); |
| 192 | if (menuEntryLoad(me, dp->d_name, shortcut)) |
| 193 | menuAddEntry(me); |
| 194 | else |
| 195 | menuDeleteEntry(me); |
| 196 | } |
| 197 | |
| 198 | closedir(dir); |
| 199 | menuSort(); |
| 200 | |
| 201 | // Swap the menu and clear the previous menu |
| 202 | s_curMenu = !s_curMenu; |
| 203 | menuClear(); |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | void menuToggleStar(menuEntry_s* me) |
| 208 | { |
no test coverage detected