static fz_off_t file_tell(fz_context *ctx, void *opaque) { FILE *file = opaque; fz_off_t off = fz_ftell(file); if (off == -1) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot ftell: %s", strerror(errno)); return off; }
static void seek_file(fz_context *ctx, fz_stream *stm, fz_off_t offset, int whence) { fz_file_stream *state = stm->state; fz_off_t n = fz_fseek(state->file, offset, whence); if (n < 0) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot seek: %s", strerror(errno)); stm->pos = fz_ftell(state->file); stm->rp = state->buffer; stm->wp = state->buffer; }