- /* Open the ZIP file and read `file' out of it */
-
- struct zip* zip = zip_open (temp_zip.c_str(), 0, 0);
- if (!zip) {
- return optional<string> (_("Could not open downloaded ZIP file"));
- }
-
- struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0);
- if (!zip_file) {
- return optional<string> (_("Unexpected ZIP file contents"));
- }
-
- ScopedTemporary temp_cert;
- f = temp_cert.open ("wb");
- char buffer[4096];
- while (1) {
- int const N = zip_fread (zip_file, buffer, sizeof (buffer));
- fwrite (buffer, 1, N, f);
- if (N < int (sizeof (buffer))) {
- break;
- }
- }
- temp_cert.close ();
-
- load (temp_cert.file ());
- return optional<string> ();