static GimpPDBStatusType save_image (const gchar *uri, gint32 image_ID, gint32 drawable_ID, gint32 run_mode, GError **error) { GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR; gchar *tmpname; tmpname = get_temp_name (uri, NULL); if (gimp_file_save (run_mode, image_ID, drawable_ID, tmpname, tmpname) && valid_file (tmpname)) { if (uri_backend_save_image (uri, tmpname, run_mode, error)) { status = GIMP_PDB_SUCCESS; } } else { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s", gimp_get_pdb_error ()); } g_unlink (tmpname); g_free (tmpname); return status; }
static GimpPDBStatusType save_image (const gchar *uri, gint32 image_ID, gint32 drawable_ID, gint32 run_mode, GError **error) { GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR; gchar *tmpname; gboolean mapped = FALSE; tmpname = uri_backend_map_image (uri, run_mode); if (tmpname) mapped = TRUE; else tmpname = get_temp_name (uri, NULL); if (gimp_file_save (run_mode, image_ID, drawable_ID, tmpname, tmpname)) { if (mapped) { status = GIMP_PDB_SUCCESS; } else if (valid_file (tmpname)) { if (uri_backend_save_image (uri, tmpname, run_mode, error)) { status = GIMP_PDB_SUCCESS; } } else { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Failed to save to temporary file '%s'"), gimp_filename_to_utf8 (tmpname)); } } else { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s", gimp_get_pdb_error ()); } if (! mapped) g_unlink (tmpname); g_free (tmpname); return status; }