/** * gsf_output_set_error: * @output: #GsfOutput * @code: The error id * @format: printf style format string * @...: arguments for @format * * <note>This is a utility routine that should only be used by derived * outputs.</note> * * Returns: Always returns %FALSE to facilitate its use. **/ gboolean gsf_output_set_error (GsfOutput *output, gint code, char const *format, ...) { g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE); g_clear_error (&output->err); if (format != NULL) { char *message; va_list args; va_start (args, format); message = g_strdup_vprintf (format, args); va_end (args); output->err = g_error_new_literal (gsf_output_error_id (), code, message); g_free (message); } return FALSE; }
/** * gsf_output_get_modtime: * @output: the output stream * * Returns: (transfer none): A #GDateTime representing when the output * was last modified, or %NULL if not known. */ GDateTime * gsf_output_get_modtime (GsfOutput *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), NULL); return g_object_get_data (G_OBJECT (output), MODTIME_ATTR); }
/** * gsf_output_bzip_new : * @sink : The underlying data source. * @err : optionally %NULL. * * Adds a reference to @sink. * * Returns: a new file or %NULL. **/ GsfOutput * gsf_output_bzip_new (GsfOutput *sink, GError **err) { #ifdef HAVE_BZ2 GsfOutputBzip *bzip; g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL); bzip = g_object_new (GSF_OUTPUT_BZIP_TYPE, NULL); if (G_UNLIKELY (NULL == bzip)) return NULL; g_object_ref (G_OBJECT (sink)); bzip->sink = sink; if (!init_bzip (bzip, err)) { g_object_unref (G_OBJECT (bzip)); return NULL; } return GSF_OUTPUT (bzip); #else (void)sink; if (err) *err = g_error_new (gsf_output_error_id (), 0, "BZ2 support not enabled"); return NULL; #endif }
/** * gsf_outfile_zip_new : * @sink: a #GsfOutput to hold the ZIP file * @err: Location to store error, or %NULL; currently unused. * * Creates the root directory of a Zip file and manages the addition of * children. * * <note>This adds a reference to @sink.</note> * * Returns: the new zip file handler **/ GsfOutfile * gsf_outfile_zip_new (GsfOutput *sink, G_GNUC_UNUSED GError **err) { g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL); return (GsfOutfile *)g_object_new (GSF_OUTFILE_ZIP_TYPE, "sink", sink, NULL); }
/** * gsf_output_set_container: * @output: #GsfOutput * @container: #GsfOutfile * * <note>This is a utility routine that should only be used by derived * outputs.</note> * * Returns: %TRUE if the assignment was ok. **/ gboolean gsf_output_set_container (GsfOutput *output, GsfOutfile *container) { g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE); if (container != NULL) g_object_ref (container); if (output->container != NULL) g_object_unref (output->container); output->container = container; return TRUE; }
/** * gsf_output_set_name: * @output: #GsfOutput * @name: the new name * * <note>This is a utility routine that should only be used by derived * outputs.</note> * * Returns: %TRUE if the assignment was ok. **/ gboolean gsf_output_set_name (GsfOutput *output, char const *name) { g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE); if (g_strcmp0 (name, output->name)) { g_free (output->name); output->name = g_strdup (name); g_object_notify (G_OBJECT (output), "name"); } return TRUE; }
/** * gsf_output_set_modtime: * @output: the output stream * @modtime: (transfer none) (allow-none): the new modification time. * * Returns: %TRUE if the assignment was ok. */ gboolean gsf_output_set_modtime (GsfOutput *output, GDateTime *modtime) { g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE); if (modtime) modtime = g_date_time_add (modtime, 0); /* Copy */ /* This actually also works for null modtime. */ g_object_set_data_full (G_OBJECT (output), MODTIME_ATTR, modtime, (GDestroyNotify)g_date_time_unref); return TRUE; }
/** * gsf_output_set_name_from_filename: * @output: the output stream * @filename: the (fs-sys encoded) filename * * <note>This is a utility routine that should only be used by derived * outputs.</note> * * Returns: %TRUE if the assignment was ok. **/ gboolean gsf_output_set_name_from_filename (GsfOutput *output, char const *filename) { char *name; gboolean res; g_return_val_if_fail (GSF_IS_OUTPUT (output), FALSE); name = filename ? g_filename_to_utf8 (filename, -1, NULL, NULL, NULL) : NULL; res = gsf_output_set_name (output, name); g_free (name); return res; }
/** * gsf_output_close: * @output: #GsfOutput * * Close a stream. * * Returns: %FALSE on error **/ gboolean gsf_output_close (GsfOutput *output) { gboolean res; g_return_val_if_fail (GSF_IS_OUTPUT (output), gsf_output_set_error (output, 0, "<internal>")); g_return_val_if_fail (!output->is_closed, gsf_output_set_error (output, 0, "<internal>")); /* The implementation will log any errors, but we can never try to * close multiple times even on failure. */ res = GET_CLASS (output)->Close (output); output->is_closed = TRUE; return res; }
ULONG STDMETHODCALLTYPE OMGSFIStorage::Release(void) { TRACE("OMGSFIStorage::Release"); ULONG result = --_referenceCount; if (_referenceCount == 0) { if (_storage != 0) { if (GSF_IS_OUTPUT(_storage)) { gsf_output_close (GSF_OUTPUT(_storage)); } g_object_unref (G_OBJECT(_storage)); _storage = 0; } delete this; } return result; }
static void go_plugin_file_saver_save (GOFileSaver const *fs, GOIOContext *io_context, GoView const *view, GsfOutput *output) { GOPluginFileSaver *pfs = GO_PLUGIN_FILE_SAVER (fs); GOPluginServiceFileSaver *service_file_saver = GO_PLUGIN_SERVICE_FILE_SAVER (pfs->service); GOErrorInfo *error = NULL; g_return_if_fail (GSF_IS_OUTPUT (output)); go_plugin_service_load (pfs->service, &error); if (error != NULL) { go_io_error_info_set (io_context, error); go_io_error_push (io_context, go_error_info_new_str ( _("Error while loading plugin for saving."))); if (!gsf_output_error (output)) gsf_output_set_error (output, 0, _("Failed to load plugin for saving")); return; } g_return_if_fail (service_file_saver->cbs.plugin_func_file_save != NULL); service_file_saver->cbs.plugin_func_file_save (fs, pfs->service, io_context, view, output); }
/** * gsf_output_error: * @output: * * Returns: (transfer none): the last error logged on the output, or %NULL. **/ GError const * gsf_output_error (GsfOutput const *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), NULL); return output->err; }
/** * gsf_output_is_closed: * @output: #GsfOutput * * Returns: %TRUE if @output has already been closed. **/ gboolean gsf_output_is_closed (GsfOutput const *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), TRUE); return output->is_closed; }
/** * gsf_output_size: * @output: #GsfOutput * * Determine the size of the output stream @output. * * Returns: the size of the output, or -1 if it does not have a size. **/ gsf_off_t gsf_output_size (GsfOutput *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), -1); return output->cur_size; }
/** * gsf_output_container: * @output: * * Returns: (transfer none): @output's container, potentially %NULL. **/ GsfOutfile * gsf_output_container (GsfOutput const *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), NULL); return output->container; }
/** * gsf_output_name: * @output: #GsfOutput * * Give the name of @output. * * Returns: (transfer none): @output's name in utf8 form. **/ char const * gsf_output_name (GsfOutput const *output) { g_return_val_if_fail (GSF_IS_OUTPUT (output), NULL); return output->name; }