software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface) const { // split full software name into software list name and short software name std::string swlist_name, swinfo_name, swpart_name; software_name_split(path, swlist_name, swinfo_name, swpart_name); // determine interface const char *interface = nullptr; if (restrict_to_interface) interface = image_interface(); // find the software list if explicitly specified software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device *swlistdev = deviter.first(); swlistdev != nullptr; swlistdev = deviter.next()) { if (swlist_name.compare(swlistdev->list_name())==0 || !(swlist_name.length() > 0)) { software_info *info = swlistdev->find(swinfo_name.c_str()); if (info != nullptr) { software_part *part = info->find_part(swpart_name.c_str(), interface); if (part != nullptr) return part; } } if (swinfo_name == swlistdev->list_name()) { // ad hoc handling for the case path = swlist_name:swinfo_name (e.g. // gameboy:sml) which is not handled properly by software_name_split // since the function cannot distinguish between this and the case // path = swinfo_name:swpart_name software_info *info = swlistdev->find(swpart_name.c_str()); if (info != nullptr) { software_part *part = info->find_part(nullptr, interface); if (part != nullptr) return part; } } } // if explicitly specified and not found, just error here return nullptr; }
software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface) { // // Note: old code would explicitly load swlist_name if it was specified, rather than // searching the devices. // // Also if not found, old code would attempt to open <drivername>.xml and even // <swinfo_name>.xml. Hopefully removing this won't break anything. // // split full software name into software list name and short software name astring swlist_name, swinfo_name, swpart_name; software_name_split(path, swlist_name, swinfo_name, swpart_name); bool explicit_name = (swlist_name.len() > 0); // determine interface const char *interface = NULL; if (restrict_to_interface) interface = image_interface(); // find the software list if explicitly specified software_list_device_iterator deviter(device().mconfig().root_device()); for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next()) if (!explicit_name || swlist_name == swlistdev->list_name()) { software_info *info = swlistdev->find(swinfo_name); if (info != NULL) { software_part *part = info->find_part(swpart_name, interface); if (part != NULL) return part; } } // if explicitly specified and not found, just error here return NULL; }