- BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
- shared_ptr<string> kdm (new string (i.kdm.as_xml ()));
- kdm_strings.push_back (kdm);
-
- struct zip_source* source = zip_source_buffer (zip, kdm->c_str(), kdm->length(), 0);
- if (!source) {
- throw runtime_error ("could not create ZIP source");
- }
-
- name_values['s'] = i.screen->name;
- string const name = name_format.get(name_values, ".xml");
- if (zip_add (zip, name.c_str(), source) == -1) {
- throw runtime_error ("failed to add KDM to ZIP archive");
- }
+ BOOST_FOREACH (shared_ptr<KDMWithMetadata> i, screen_kdms) {
+ name_values['s'] = i->screen->name;
+ name_values['i'] = i->kdm_id ();
+ string const name = careful_string_filter(name_format.get(name_values, ".xml"));
+ zipper.add (name, i->kdm_as_xml());