fz_archive * fz_open_archive_with_stream(fz_context *ctx, fz_stream *file) { fz_archive *arch = NULL; fz_try(ctx) { if (fz_is_zip_archive(ctx, file)) arch = fz_open_zip_archive_with_stream(ctx, file); else if (fz_is_tar_archive(ctx, file)) arch = fz_open_tar_archive_with_stream(ctx, file); else fz_throw(ctx, FZ_ERROR_GENERIC, "cannot recognize archive"); } fz_catch(ctx) fz_rethrow(ctx); return arch; }
fz_document * xps_open_document_with_stream(fz_context *ctx, fz_stream *file) { xps_document *doc; doc = fz_malloc_struct(ctx, xps_document); xps_init_document(ctx, doc); fz_try(ctx) { doc->zip = fz_open_zip_archive_with_stream(ctx, file); xps_read_page_list(ctx, doc); } fz_catch(ctx) { fz_drop_document(ctx, &doc->super); fz_rethrow(ctx); } return (fz_document*)doc; }
static fz_document * epub_open_document_with_stream(fz_context *ctx, fz_stream *file) { return epub_init(ctx, fz_open_zip_archive_with_stream(ctx, file)); }