Previous 15994 Revisions Next

r8175 Wednesday 26th May, 2010 at 17:32:26 UTC by Firewave
Moved filename_basename() ti utils.c and removed redundant implementation
[src/mess]image.c mess.c utils.c utils.h

src/mess/utils.c
r8174r8175
364364
365365   return error;
366366}
367
368//============================================================
369//  filename_basename
370//============================================================
371
372const char *filename_basename(const char *filename)
373{
374   const char *c;
375
376   // NULL begets NULL
377   if (!filename)
378      return NULL;
379
380   // start at the end and return when we hit a slash or colon
381   for (c = filename + strlen(filename) - 1; c >= filename; c--)
382      if (*c == '\\' || *c == '/' || *c == ':')
383         return c + 1;
384
385   // otherwise, return the whole thing
386   return filename;
387}
src/mess/utils.h
r8174r8175
200200/* validity checks */
201201int utils_validitychecks(void);
202202
203const char *filename_basename(const char *filename);
204
203205#endif /* UTILS_H */
src/mess/mess.c
r8174r8175
3030      "with these files is a violation of copyright law and should be promptly\n"
3131      "reported to the authors so that appropriate legal action can be taken.\n\n";
3232
33static char *filename_basename(char *filename)
34{
35   char *c;
36
37   // NULL begets NULL
38   if (!filename)
39      return NULL;
40
41   // start at the end and return when we hit a slash or colon
42   for (c = filename + strlen(filename) - 1; c >= filename; c--)
43      if (*c == '\\' || *c == '/' || *c == ':')
44         return c + 1;
45
46   // otherwise, return the whole thing
47   return filename;
48}
49
5033/*-------------------------------------------------
5134    mess_predevice_init - initialize devices for a specific
5235    running_machine
r8174r8175
8871            {
8972               /* retrieve image error message */
9073               const char *image_err = image_error(image);
91               char *image_basename = auto_strdup(machine, filename_basename((char *)image_name));
74               char *image_basename = auto_strdup(machine, filename_basename(image_name));
9275
9376               /* unload all images */
9477               image_unload_all(machine);
src/mess/image.c
r8174r8175
12601260}
12611261
12621262
1263//============================================================
1264//  image_filename_basename
1265//============================================================
12661263
1267static char *image_filename_basename(char *filename)
1268{
1269   char *c;
1270
1271   // NULL begets NULL
1272   if (!filename)
1273      return NULL;
1274
1275   // start at the end and return when we hit a slash or colon
1276   for (c = filename + strlen(filename) - 1; c >= filename; c--)
1277      if (*c == '\\' || *c == '/' || *c == ':')
1278         return c + 1;
1279
1280   // otherwise, return the whole thing
1281   return filename;
1282}
1283
12841264/*-------------------------------------------------
12851265    image_basename
12861266-------------------------------------------------*/
12871267
12881268const char *image_basename(running_device *image)
12891269{
1290    return image_filename_basename((char *) image_filename(image));
1270    return filename_basename(image_filename(image));
12911271}
12921272
12931273

Previous 15994 Revisions Next


© 1998-2018 The MESS Team