diff options
Diffstat (limited to 'source/fitz/stream-read.c')
-rw-r--r-- | source/fitz/stream-read.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index de314fe4..3144974e 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -161,3 +161,28 @@ int fz_stream_meta(fz_stream *stm, int key, int size, void *ptr) return -1; return stm->meta(stm, key, size, ptr); } + +fz_buffer * +fz_read_file(fz_context *ctx, const char *filename) +{ + fz_stream *stm; + fz_buffer *buf = NULL; + + fz_var(buf); + + stm = fz_open_file(ctx, filename); + fz_try(ctx) + { + buf = fz_read_all(stm, 0); + } + fz_always(ctx) + { + fz_close(stm); + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } + + return buf; +} |