[cairo-commit] 3 commits - src/cairoint.h src/cairo-output-stream.c
src/cairo-ps-surface.c
Carl Worth
cworth at kemper.freedesktop.org
Wed Apr 12 14:13:16 PDT 2006
src/cairo-output-stream.c | 11 ++++++++---
src/cairo-ps-surface.c | 9 +++++++--
src/cairoint.h | 7 +++++++
3 files changed, 22 insertions(+), 5 deletions(-)
New commits:
diff-tree b30e281627d86f3c0d0f4d5008bbbf7e77c09350 (from 193b43001de11945b0ae7ca4ee685590d9f79137)
Author: Carl Worth <cworth at cworth.org>
Date: Wed Apr 12 13:55:24 2006 -0700
Add documentation for _cairo_output_stream_create_for_file.
diff --git a/src/cairoint.h b/src/cairoint.h
index 4cfa948..13880cb 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2192,6 +2192,13 @@ _cairo_output_stream_get_status (cairo_o
cairo_private cairo_output_stream_t *
_cairo_output_stream_create_for_filename (const char *filename);
+/* This function never returns NULL. If an error occurs (NO_MEMORY or
+ * WRITE_ERROR) while trying to create the output stream this function
+ * returns a valid pointer to a nil output stream.
+ *
+ * The caller still "owns" file and is responsible for calling fclose
+ * on it when finished. The stream will not do this itself.
+ */
cairo_private cairo_output_stream_t *
_cairo_output_stream_create_for_file (FILE *file);
diff-tree 193b43001de11945b0ae7ca4ee685590d9f79137 (from d9137e56b6a8f1ddb44a01bf34301117b0696f0b)
Author: Carl Worth <cworth at cworth.org>
Date: Wed Apr 12 14:06:26 2006 -0700
Propagate stream status values through _cairo_ps_surface_finish
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index ef4b89c..2787538 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -322,10 +322,10 @@ cairo_ps_surface_set_dpi (cairo_surface_
#endif
}
-/* XXX */
static cairo_status_t
_cairo_ps_surface_finish (void *abstract_surface)
{
+ cairo_status_t status;
cairo_ps_surface_t *surface = abstract_surface;
_cairo_ps_surface_emit_header (surface);
@@ -345,13 +345,18 @@ _cairo_ps_surface_finish (void *abstract
_cairo_array_fini (&surface->fonts);
#endif
+ _cairo_output_stream_close (surface->stream);
+ status = _cairo_output_stream_get_status (surface->stream);
_cairo_output_stream_destroy (surface->stream);
fclose (surface->tmpfile);
+ _cairo_output_stream_close (surface->final_stream);
+ if (status == CAIRO_STATUS_SUCCESS)
+ status = _cairo_output_stream_get_status (surface->final_stream);
_cairo_output_stream_destroy (surface->final_stream);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static void
diff-tree d9137e56b6a8f1ddb44a01bf34301117b0696f0b (from 32994379db92ef8208ba11b825b1246e2b442566)
Author: Carl Worth <cworth at cworth.org>
Date: Wed Apr 12 13:44:14 2006 -0700
Use ferror to get error checking for stdio-based output streams.
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 3b53aa9..e9b5727 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -339,18 +339,23 @@ stdio_flush (void *closure)
fflush (file);
- return CAIRO_STATUS_SUCCESS; /* XXX errors */
+ if (ferror (file))
+ return CAIRO_STATUS_WRITE_ERROR;
+ else
+ return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
stdio_close (void *closure)
{
+ cairo_status_t status;
FILE *file = closure;
- fflush (file);
+ status = stdio_flush (closure);
+
fclose (file);
- return CAIRO_STATUS_SUCCESS; /* XXX errors */
+ return status;
}
cairo_output_stream_t *
More information about the cairo-commit
mailing list