From a636786a2ea58082004f46ef34382e7f4c294e2d Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 3 Mar 2016 13:06:23 +0100 Subject: js: Add buffer.save() to write contents of buffer to file. --- source/fitz/output.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/fitz/output.c') diff --git a/source/fitz/output.c b/source/fitz/output.c index 0dd0eb04..ed6e89a3 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -186,3 +186,15 @@ fz_printf(fz_context *ctx, fz_output *out, const char *fmt, ...) fz_vprintf(ctx, out, fmt, args); va_end(args); } + +void +fz_save_buffer(fz_context *ctx, fz_buffer *buf, const char *filename) +{ + fz_output *out = fz_new_output_with_path(ctx, filename, 0); + fz_try(ctx) + fz_write(ctx, out, buf->data, buf->len); + fz_always(ctx) + fz_drop_output(ctx, out); + fz_catch(ctx) + fz_rethrow(ctx); +} -- cgit v1.2.3