[cairo] Better error return for cairo_pdf_surface_create

Nick Wellnhofer wellnhofer at aevum.de
Wed Feb 14 07:23:13 PST 2007

Carl Worth wrote:
> On Sat, 20 Jan 2007 21:15:36 +0100, Nick Wellnhofer wrote:
>> Currently, cairo_pdf_surface_create always returns
>> CAIRO_STATUS_NO_MEMORY if an error occurs. The attached patch makes it
>> possible to distinguish at least between memory and file related errors.
> Thanks for the patch. It looks like Eugeniy already committed a
> similar fix:
> http://gitweb.freedesktop.org/?p=cairo;a=commitdiff;h=a37f21cb17a24643f7513dff06bc2b5fd38e2583
> It doesn't add the READ_ERROR and FILE_NOT_FOUND cases but those
> really aren't possible for surface_create anyway, (well it could
> be useful to distinguish between a non-existent destination directory
> as opposed to some other write error, but neither the original patch
> nor what was committed do that).

FILE_NOT_FOUND is entirely possible for PDF surfaces, if you pass a 
filename with a directory that doesn't exist. The cleanest solution 
would be to check errno when fopen in create_output_stream fails. But 
for the moment I only need to distinguish IO errors from an out of 
memory condition.


aevum gmbh
leopoldstr. 41
80802 münchen

fon: +4989 38380653
wellnhofer at aevum.de

More information about the cairo mailing list