static astring *assemble_software_path(astring *str, const game_driver *gamedrv, const char *filename) { if (osd_is_absolute_path(filename)) astring_cpyc(str, filename); else astring_assemble_5(str, "software", PATH_SEPARATOR, gamedrv->name, PATH_SEPARATOR, filename); return str; }
static char *assemble_software_path(const game_driver *gamedrv, const char *filename) { char *result; if (osd_is_absolute_path(filename)) result = mame_strdup(filename); else result = assemble_5_strings("software", PATH_SEPARATOR, gamedrv->name, PATH_SEPARATOR, filename); return result; }
void running_machine::set_saveload_filename(const char *filename) { // free any existing request and allocate a copy of the requested name if (osd_is_absolute_path(filename)) { m_saveload_searchpath = NULL; m_saveload_pending_file.cpy(filename); } else { m_saveload_searchpath = options().state_directory(); m_saveload_pending_file.cpy(basename()).cat(PATH_SEPARATOR).cat(filename).cat(".sta"); } }
void running_machine::set_saveload_filename(const char *filename) { // free any existing request and allocate a copy of the requested name if (osd_is_absolute_path(filename)) { m_saveload_searchpath = NULL; m_saveload_pending_file.cpy(filename); } else { m_saveload_searchpath = options().state_directory(); // take into account the statename option const char *stateopt = options().state_name(); astring statename = get_statename(stateopt); m_saveload_pending_file.cpy(statename.cstr()).cat(PATH_SEPARATOR).cat(filename).cat(".sta"); } }
static void compose_path(char *output, size_t outputlen, int pathtype, int pathindex, const char *filename) { const char *basepath = get_path_for_filetype(pathtype, pathindex, NULL); char *p; #ifdef MESS if (osd_is_absolute_path(filename)) basepath = NULL; #endif /* compose the full path */ *output = 0; if (basepath) strncat(output, basepath, outputlen - strlen(output) - 1); if (*output && !is_pathsep(output[strlen(output) - 1])) strncat(output, "/", outputlen - strlen(output) - 1); strncat(output, filename, outputlen - strlen(output) - 1); /* convert backslashes to forward slashes */ for (p = output; *p; p++) if (*p == '\\') *p = '/'; }
std::string &zippath_combine(std::string &dst, const char *path1, const char *path2) { if (!strcmp(path2, ".")) { dst.assign(path1); } else if (!strcmp(path2, "..")) { zippath_parent(dst, path1); } else if (osd_is_absolute_path(path2)) { dst.assign(path2); } else if ((path1[0] != '\0') && !is_path_separator(path1[strlen(path1) - 1])) { dst.assign(path1).append(PATH_SEPARATOR).append(path2); } else { dst.assign(path1).append(path2); } return dst; }
path_iterator::path_iterator(core_options &opts, const char *searchpath) : m_base((searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(&opts, searchpath) : ""), m_current(m_base), m_index(0) { }
static mame_file *image_fopen_custom(mess_image *img, int filetype, int read_or_write) { const char *sysname; char *lpExt; const game_driver *gamedrv = Machine->gamedrv; assert(img); if (!img->name) return NULL; if (img->fp) { /* If already open, we won't open the file again until it is closed. */ return NULL; } do { sysname = gamedrv->name; logerror("image_fopen: trying %s for system %s\n", img->name, sysname); img->fp = mame_fopen(sysname, img->name, filetype, read_or_write); if (img->fp && (read_or_write == OSD_FOPEN_READ)) { lpExt = strrchr( img->name, '.' ); if (lpExt && (mame_stricmp( lpExt, ".ZIP" ) == 0)) { int pathindex; int pathcount = osd_get_path_count(filetype); zip_file *zipfile; zip_entry *zipentry; char *newname; char *name; char *zipname; const char *ext; const struct IODevice *dev; mame_fclose( img->fp ); img->fp = NULL; dev = image_device(img); assert(dev); newname = NULL; zipname = image_malloc( img, strlen( sysname ) + 1 + strlen( img->name ) + 1 ); if( osd_is_absolute_path( img->name ) ) { strcpy( zipname, img->name ); } else { strcpy( zipname, sysname ); strcat( zipname, osd_path_separator() ); strcat( zipname, img->name ); } for (pathindex = 0; pathindex < pathcount; pathindex++) { zipfile = openzip(filetype, pathindex, zipname); if (zipfile) { zipentry = readzip(zipfile); while( zipentry ) { /* mess doesn't support paths in zip files */ name = osd_basename( zipentry->name ); lpExt = strrchr(name, '.'); if (lpExt) { lpExt++; ext = dev->file_extensions; while(*ext) { if( mame_stricmp( lpExt, ext ) == 0 ) { if( newname ) { image_freeptr( img, newname ); } newname = image_malloc(img, strlen(img->name) + 1 + strlen(name) + 1); if (!newname) return NULL; strcpy(newname, img->name); strcat(newname, osd_path_separator()); strcat(newname, name); } ext += strlen(ext) + 1; } } zipentry = readzip(zipfile); } closezip(zipfile); } if( !newname ) { return NULL; } img->fp = mame_fopen(sysname, newname, filetype, read_or_write); if (img->fp) { image_freeptr(img, img->name); img->name = newname; break; } } image_freeptr( img, zipname ); } } gamedrv = mess_next_compatible_driver(gamedrv); } while(!img->fp && gamedrv); if (img->fp) { logerror("image_fopen: found image %s for system %s\n", img->name, sysname); img->length = mame_fsize(img->fp); img->hash = NULL; } return img->fp; }