| 132 | } |
| 133 | |
| 134 | void menuEntryFileAssocLoad(const char* filepath) |
| 135 | { |
| 136 | bool success = false; |
| 137 | bool iconLoaded = false; |
| 138 | |
| 139 | menuEntry_s* entry = NULL; |
| 140 | |
| 141 | config_setting_t* fileAssoc = NULL; |
| 142 | config_setting_t* targets = NULL; |
| 143 | config_setting_t* target = NULL; |
| 144 | config_setting_t* appArguments = NULL; |
| 145 | config_setting_t* targetArguments = NULL; |
| 146 | |
| 147 | config_t config = {0}; |
| 148 | |
| 149 | int targetsLength = 0; |
| 150 | int argsLength = 0; |
| 151 | int index = 0; |
| 152 | |
| 153 | char appPath[PATH_MAX + 8]; |
| 154 | char mainIconPath[PATH_MAX + 1]; |
| 155 | char targetIconPath[PATH_MAX + 1]; |
| 156 | char targetFileExtension[PATH_MAX + 1]; |
| 157 | char targetFilename[PATH_MAX + 1]; |
| 158 | |
| 159 | char appAuthor[ENTRY_AUTHORLENGTH + 2]; |
| 160 | char appDescription[ENTRY_DESCLENGTH + 2]; |
| 161 | |
| 162 | const char* stringValue = NULL; |
| 163 | |
| 164 | config_init(&config); |
| 165 | |
| 166 | memset(appPath, 0, sizeof(appPath)); |
| 167 | memset(mainIconPath, 0, sizeof(mainIconPath)); |
| 168 | memset(appAuthor, 0, sizeof(appAuthor)); |
| 169 | memset(appDescription, 0, sizeof(appDescription)); |
| 170 | |
| 171 | |
| 172 | if (!fileExists(filepath)) |
| 173 | return; |
| 174 | |
| 175 | if (config_read_file(&config, filepath)) { |
| 176 | |
| 177 | fileAssoc = config_lookup(&config, "fileassoc"); |
| 178 | |
| 179 | if (fileAssoc != NULL) { |
| 180 | if (config_setting_lookup_string(fileAssoc, "app_path", &stringValue)) |
| 181 | snprintf(appPath, sizeof(appPath) - 1, "%s%s", menuGetRootBasePath(), stringValue); |
| 182 | |
| 183 | if (config_setting_lookup_string(fileAssoc, "icon_path", &stringValue)) |
| 184 | snprintf(mainIconPath, sizeof(mainIconPath) - 1, "%s%s", menuGetRootBasePath(), stringValue); |
| 185 | |
| 186 | appArguments = config_setting_lookup(fileAssoc, "app_args"); |
| 187 | targets = config_setting_lookup(fileAssoc, "targets"); |
| 188 | |
| 189 | if (appPath[0] && targets) { |
| 190 | targetsLength = config_setting_length(targets); |
| 191 |
no test coverage detected