struct output_driver driver;
struct zip_writer *zip; /* ZIP file writer. */
+ struct file_handle *handle; /* Handle for 'file_name'. */
char *file_name; /* Output file name. */
/* content.xml */
return UP_CAST (driver, struct odt_driver, driver);
}
-/* Create the "mimetype" file needed by ODF */
-static bool
-create_mimetype (struct zip_writer *zip)
-{
- FILE *fp;
-
- fp = create_temp_file ();
- if (fp == NULL)
- {
- msg_error (errno, _("error creating temporary file"));
- return false;
- }
-
- fprintf (fp, "application/vnd.oasis.opendocument.text");
- zip_writer_add (zip, fp, "mimetype");
- close_temp_file (fp);
-
- return true;
-}
-
/* Creates a new temporary file and stores it in *FILE, then creates an XML
writer for it and stores it in *W. */
static void
output_driver_init (d, &odt_driver_class, file_name, device_type);
odt->zip = zip;
+ odt->handle = fh;
odt->file_name = xstrdup (file_name);
- if (!create_mimetype (zip))
- {
- output_driver_destroy (d);
- return NULL;
- }
+ zip_writer_add_string (zip, "mimetype",
+ "application/vnd.oasis.opendocument.text");
/* Create the manifest */
create_writer (&odt->manifest_file, &odt->manifest_wtr);
zip_writer_close (odt->zip);
}
+ fh_unref (odt->handle);
free (odt->file_name);
free (odt);
}