X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fodt.c;h=a3f945421f00e351fc8e84a08a56f435dc7d95b1;hb=f967d0e36a2193c1249799f463ea9109b753f7a8;hp=56b26bb1ac6db335c8227d651e8bb7b7087b2e43;hpb=5cab4cf3322f29c0ed7134d23740e07382914f20;p=pspp diff --git a/src/output/odt.c b/src/output/odt.c index 56b26bb1ac..a3f945421f 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -56,6 +56,7 @@ struct odt_driver 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 */ @@ -79,26 +80,6 @@ odt_driver_cast (struct output_driver *driver) 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 @@ -302,13 +283,11 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, 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); @@ -379,6 +358,7 @@ odt_destroy (struct output_driver *driver) zip_writer_close (odt->zip); } + fh_unref (odt->handle); free (odt->file_name); free (odt); }