X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fcinema_kdms.cc;h=3af1e0d84ca7c1ec932c635c9cfa223d32153e2f;hp=32879cf6b5763355378e6ddc58432b8095d8ef52;hb=4ead1f24f97edde9b6a77e47947cb188a551b49b;hpb=006e38346a8bcdcc889979b7c00802d9bb8fc6f8 diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 32879cf6b..3af1e0d84 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -27,8 +27,8 @@ #include "emailer.h" #include "compose.hpp" #include "log.h" +#include "zipper.h" #include "dcpomatic_log.h" -#include #include #include "i18n.h" @@ -43,39 +43,18 @@ using boost::function; void CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const { - int error; - struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error); - if (!zip) { - if (error == ZIP_ER_EXISTS) { - throw FileError ("ZIP file already exists", zip_file); - } - throw FileError ("could not create ZIP file", zip_file); - } - - list > kdm_strings; + Zipper zipper (zip_file); name_values['c'] = cinema->name; BOOST_FOREACH (shared_ptr i, screen_kdms) { - shared_ptr 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; name_values['i'] = i->kdm_id (); string const name = careful_string_filter(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"); - } + zipper.add (name, i->kdm_as_xml()); } - if (zip_close (zip) == -1) { - throw runtime_error ("failed to close ZIP archive"); - } + zipper.close (); } /** Collect a list of ScreenKDMs into a list of CinemaKDMs so that each