src/mess/image.c
| r2269 | r2270 | |
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | /**************************************************************************** |
| 271 | ANALYSIS |
| 272 | ****************************************************************************/ |
| 273 | |
| 274 | /*------------------------------------------------- |
| 275 | image_device_uses_file_extension - checks to |
| 276 | see if a particular devices uses a certain |
| 277 | file extension |
| 278 | -------------------------------------------------*/ |
| 279 | |
| 280 | int image_device_uses_file_extension(const device_config *device, const char *file_extension) |
| 281 | { |
| 282 | int result = FALSE; |
| 283 | const struct IODevice *iodev; |
| 284 | |
| 285 | /* skip initial period, if present */ |
| 286 | if (file_extension[0] == '.') |
| 287 | file_extension++; |
| 288 | |
| 289 | iodev = mess_device_from_core_device(device); |
| 290 | if (iodev != NULL) |
| 291 | { |
| 292 | const char *s = iodev->file_extensions; |
| 293 | while(!result && (*s != '\0')) |
| 294 | { |
| 295 | if (!mame_stricmp(s, file_extension)) |
| 296 | { |
| 297 | result = TRUE; |
| 298 | break; |
| 299 | } |
| 300 | s += strlen(s) + 1; |
| 301 | } |
| 302 | } |
| 303 | return result; |
| 304 | } |
| 305 | |
| 306 | |
| 307 | |
| 308 | /**************************************************************************** |
| 271 | 309 | IMAGE LOADING |
| 272 | 310 | ****************************************************************************/ |
| 273 | 311 | |
src/mess/osd/winui/messui.c
| r2269 | r2270 | |
| 438 | 438 | |
| 439 | 439 | |
| 440 | 440 | |
| 441 | | static int device_uses_file_extension(const device_config *device, const char *file_extension) |
| 442 | | { |
| 443 | | int result = FALSE; |
| 444 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 445 | | if (iodev != NULL) |
| 446 | | { |
| 447 | | const char *s = iodev->file_extensions; |
| 448 | | if (s != NULL) |
| 449 | | { |
| 450 | | while(!result && (*s != '\0')) |
| 451 | | { |
| 452 | | if (!mame_stricmp(s, file_extension)) |
| 453 | | { |
| 454 | | result = TRUE; |
| 455 | | break; |
| 456 | | } |
| 457 | | s += strlen(s) + 1; |
| 458 | | } |
| 459 | | } |
| 460 | | } |
| 461 | | return result; |
| 462 | | } |
| 463 | | |
| 464 | | |
| 465 | | |
| 466 | 441 | // Places the specified image in the specified slot; nID = -1 means don't matter |
| 467 | 442 | static void MessSpecifyImage(int drvindex, const device_config *device, LPCSTR pszFilename) |
| 468 | 443 | { |
| r2269 | r2270 | |
| 499 | 474 | { |
| 500 | 475 | for (device = image_device_first(config); device != NULL; device = image_device_next(device)) |
| 501 | 476 | { |
| 502 | | if (device_uses_file_extension(device, file_extension)) |
| 477 | if (image_device_uses_file_extension(device, file_extension)) |
| 503 | 478 | break; |
| 504 | 479 | } |
| 505 | 480 | } |
src/mess/osd/winui/softwarepicker.c
| r2269 | r2270 | |
| 427 | 427 | file_info **ppNewIndex; |
| 428 | 428 | file_info *pInfo; |
| 429 | 429 | int nIndex, nSize; |
| 430 | | LPCSTR pszExtension = NULL, s; |
| 430 | LPCSTR pszExtension = NULL; |
| 431 | 431 | const device_config *device = NULL; |
| 432 | 432 | |
| 433 | 433 | // first check to see if it is already here |
| r2269 | r2270 | |
| 441 | 441 | pszExtension = strrchr(pszFilename, '.'); |
| 442 | 442 | if ((pszExtension != NULL) && (pPickerInfo->pDriver != NULL)) |
| 443 | 443 | { |
| 444 | | // skip the initial '.' in the file extension |
| 445 | | pszExtension++; |
| 446 | | |
| 447 | 444 | for (device = image_device_first(pPickerInfo->pConfig); device != NULL; device = image_device_next(device)) |
| 448 | 445 | { |
| 449 | | const struct IODevice *iodev = mess_device_from_core_device(device); |
| 450 | | |
| 451 | | s = iodev->file_extensions; |
| 452 | | if (s != NULL) |
| 453 | | { |
| 454 | | while(*s && mame_stricmp(pszExtension, s)) |
| 455 | | s += strlen(s) + 1; |
| 456 | | if (*s) |
| 457 | | break; |
| 458 | | } |
| 446 | if (image_device_uses_file_extension(device, pszExtension)) |
| 447 | break; |
| 459 | 448 | } |
| 460 | 449 | } |
| 461 | 450 | |