static chd_file *get_disc(const device_config *device) { mame_file *image_file = NULL; chd_file *image_chd = NULL; mame_path *path; /* open a path to the ROMs and find the first CHD file */ path = mame_openpath(mame_options(), OPTION_ROMPATH); if (path != NULL) { const osd_directory_entry *dir; /* iterate while we get new objects */ while ((dir = mame_readpath(path)) != NULL) { int length = strlen(dir->name); /* look for files ending in .chd */ if (length > 4 && dir->name[length - 4] == '.' && tolower(dir->name[length - 3]) == 'c' && tolower(dir->name[length - 2]) == 'h' && tolower(dir->name[length - 1]) == 'd') { file_error filerr; chd_error chderr; /* open the file itself via our search path */ filerr = mame_fopen(SEARCHPATH_IMAGE, dir->name, OPEN_FLAG_READ, &image_file); if (filerr == FILERR_NONE) { /* try to open the CHD */ chderr = chd_open_file(mame_core_file(image_file), CHD_OPEN_READ, NULL, &image_chd); if (chderr == CHDERR_NONE) { set_disk_handle(device->machine, "laserdisc", image_file, image_chd); filename = astring_dupc(dir->name); add_exit_callback(device->machine, free_string); break; } /* close the file on failure */ mame_fclose(image_file); image_file = NULL; } } } mame_closepath(path); } /* if we failed, pop a message and exit */ if (image_file == NULL) fatalerror("No valid image file found!\n"); return get_disk_handle(device->machine, "laserdisc"); }
chd_file *ldplayer_state::get_disc() { // open a path to the ROMs and find the first CHD file file_enumerator path(machine().options().media_path()); // iterate while we get new objects const osd_directory_entry *dir; emu_file *image_file = NULL; chd_file *image_chd = NULL; while ((dir = path.next()) != NULL) { int length = strlen(dir->name); // look for files ending in .chd if (length > 4 && dir->name[length - 4] == '.' && tolower(dir->name[length - 3]) == 'c' && tolower(dir->name[length - 2]) == 'h' && tolower(dir->name[length - 1]) == 'd') { // open the file itself via our search path image_file = auto_alloc(machine(), emu_file(machine().options().media_path(), OPEN_FLAG_READ)); file_error filerr = image_file->open(dir->name); if (filerr == FILERR_NONE) { // try to open the CHD chd_error chderr = chd_open_file(*image_file, CHD_OPEN_READ, NULL, &image_chd); if (chderr == CHDERR_NONE) { set_disk_handle(machine(), "laserdisc", *image_file, *image_chd); m_filename.cpy(dir->name); break; } } // close the file on failure auto_free(machine(), image_file); image_file = NULL; } } // if we failed, pop a message and exit if (image_file == NULL) throw emu_fatalerror("No valid image file found!\n"); return get_disk_handle(machine(), "laserdisc"); }
chd_file *ldplayer_state::get_disc() { bool found = FALSE; // open a path to the ROMs and find the first CHD file file_enumerator path(machine().options().media_path()); // iterate while we get new objects const osd_directory_entry *dir; while ((dir = path.next()) != NULL) { int length = strlen(dir->name); // look for files ending in .chd if (length > 4 && dir->name[length - 4] == '.' && tolower(dir->name[length - 3]) == 'c' && tolower(dir->name[length - 2]) == 'h' && tolower(dir->name[length - 1]) == 'd') { // open the file itself via our search path emu_file image_file(machine().options().media_path(), OPEN_FLAG_READ); file_error filerr = image_file.open(dir->name); if (filerr == FILERR_NONE) { astring fullpath(image_file.fullpath()); image_file.close(); // try to open the CHD if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE) { m_filename.cpy(dir->name); found = TRUE; break; } } } } // if we failed, pop a message and exit if (found == FALSE) throw emu_fatalerror("No valid image file found!\n"); return get_disk_handle(machine(), "laserdisc"); }
chd_file *ldplayer_state::get_disc() { // open a path to the ROMs and find the first CHD file file_enumerator path(machine().options().media_path()); // iterate while we get new objects const osd_directory_entry *dir; while ((dir = path.next()) != NULL) { int length = strlen(dir->name); // look for files ending in .chd if (length > 4 && dir->name[length - 4] == '.' && tolower(dir->name[length - 3]) == 'c' && tolower(dir->name[length - 2]) == 'h' && tolower(dir->name[length - 1]) == 'd') { // open the file itself via our search path emu_file image_file(machine().options().media_path(), OPEN_FLAG_READ); file_error filerr = image_file.open(dir->name); if (filerr == FILERR_NONE) { astring fullpath(image_file->fullpath(); image_file.close(); // try to open the CHD if (set_disk_handle(machine(), "laserdisc", fullpath) == CHDERR_NONE) { m_filename.cpy(dir->name); break; } } // close the file on failure auto_free(machine(), image_file); image_file = NULL; }