Previous 15994 Revisions Next

r2270 Saturday 5th April, 2008 at 14:28:16 UTC by Nathan Woods
Created an image_device_uses_file_extension() core API
[src/mess]image.c image.h
[src/mess/osd/winui]messui.c softwarepicker.c

src/mess/image.c
r2269r2270
268268
269269
270270/****************************************************************************
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
280int 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/****************************************************************************
271309    IMAGE LOADING
272310****************************************************************************/
273311
src/mess/image.h
r2269r2270
9797/* counts the number of devices that support images */
9898int image_device_count(const machine_config *config);
9999
100/* ----- analysis ----- */
100101
102/* checks to see if a particular devices uses a certain file extension */
103int image_device_uses_file_extension(const device_config *device, const char *file_extension);
101104
105
106
102107/****************************************************************************
103108  Device loading and unloading functions
104109
src/mess/osd/winui/messui.c
r2269r2270
438438
439439
440440
441static 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
466441// Places the specified image in the specified slot; nID = -1 means don't matter
467442static void MessSpecifyImage(int drvindex, const device_config *device, LPCSTR pszFilename)
468443{
r2269r2270
499474      {
500475         for (device = image_device_first(config); device != NULL; device = image_device_next(device))
501476         {
502            if (device_uses_file_extension(device, file_extension))
477            if (image_device_uses_file_extension(device, file_extension))
503478               break;
504479         }
505480      }
src/mess/osd/winui/softwarepicker.c
r2269r2270
427427   file_info **ppNewIndex;
428428   file_info *pInfo;
429429   int nIndex, nSize;
430   LPCSTR pszExtension = NULL, s;
430   LPCSTR pszExtension = NULL;
431431   const device_config *device = NULL;
432432
433433   // first check to see if it is already here
r2269r2270
441441      pszExtension = strrchr(pszFilename, '.');
442442   if ((pszExtension != NULL) && (pPickerInfo->pDriver != NULL))
443443   {
444      // skip the initial '.' in the file extension
445      pszExtension++;
446
447444      for (device = image_device_first(pPickerInfo->pConfig); device != NULL; device = image_device_next(device))
448445      {
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;
459448      }
460449   }
461450

Previous 15994 Revisions Next


© 1998-2018 The MESS Team