src/mess/mess.c
| r8174 | r8175 | |
| 30 | 30 | "with these files is a violation of copyright law and should be promptly\n" |
| 31 | 31 | "reported to the authors so that appropriate legal action can be taken.\n\n"; |
| 32 | 32 | |
| 33 | | static 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 | | |
| 50 | 33 | /*------------------------------------------------- |
| 51 | 34 | mess_predevice_init - initialize devices for a specific |
| 52 | 35 | running_machine |
| r8174 | r8175 | |
| 88 | 71 | { |
| 89 | 72 | /* retrieve image error message */ |
| 90 | 73 | 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)); |
| 92 | 75 | |
| 93 | 76 | /* unload all images */ |
| 94 | 77 | image_unload_all(machine); |
src/mess/image.c
| r8174 | r8175 | |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | |
| 1263 | | //============================================================ |
| 1264 | | // image_filename_basename |
| 1265 | | //============================================================ |
| 1266 | 1263 | |
| 1267 | | static 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 | | |
| 1284 | 1264 | /*------------------------------------------------- |
| 1285 | 1265 | image_basename |
| 1286 | 1266 | -------------------------------------------------*/ |
| 1287 | 1267 | |
| 1288 | 1268 | const char *image_basename(running_device *image) |
| 1289 | 1269 | { |
| 1290 | | return image_filename_basename((char *) image_filename(image)); |
| 1270 | return filename_basename(image_filename(image)); |
| 1291 | 1271 | } |
| 1292 | 1272 | |
| 1293 | 1273 | |