From 1a153d7899dce54cccf6cc873bec3eb821988a10 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 21 Oct 2017 14:02:55 +0000 Subject: Fl_SVG_Image: remove use of gzdirect() that is absent in some old versions of zlib git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12519 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_SVG_Image.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Fl_SVG_Image.cxx') diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx index d631e6a76..557388c49 100644 --- a/src/Fl_SVG_Image.cxx +++ b/src/Fl_SVG_Image.cxx @@ -79,15 +79,19 @@ float Fl_SVG_Image::svg_scaling_(int W, int H) { #if defined(HAVE_LIBZ) static char *svg_inflate(const char *fname) { - struct stat b; - fl_stat(fname, &b); - long size = b.st_size; + FILE *in = fl_fopen(fname, "r"); + if (!in) return NULL; + unsigned char header[2]; + fread(header, 2, 1, in); + int direct = (header[0] != 0x1f || header[1] != 0x8b); + fseek(in, 0, SEEK_END); + long size = ftell(in); + fclose(in); int fd = fl_open_ext(fname, 1, 0); if (fd < 0) return NULL; gzFile gzf = gzdopen(fd, "r"); if (!gzf) return NULL; int l; - int direct = gzdirect(gzf); long out_size = direct ? size + 1 : 3*size + 1; char *out = (char*)malloc(out_size); char *p = out; -- cgit v1.2.3