Fl_SVG_Image::fl_gzopen(): write it more platform-independently (still not completely though)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12480 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
63420dd956
commit
784ff3b52d
@ -28,6 +28,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(HAVE_LIBZ)
|
#if defined(HAVE_LIBZ)
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
# ifdef _WIN32
|
||||||
|
# include <fcntl.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_LONG_LONG)
|
#if !defined(HAVE_LONG_LONG)
|
||||||
@ -79,18 +82,13 @@ float Fl_SVG_Image::svg_scaling_(int W, int H) {
|
|||||||
/** Opens for reading a potentially gzip'ed file identified by a UTF-8 encoded filename. */
|
/** Opens for reading a potentially gzip'ed file identified by a UTF-8 encoded filename. */
|
||||||
void* Fl_SVG_Image::fl_gzopen(const char *fname) {
|
void* Fl_SVG_Image::fl_gzopen(const char *fname) {
|
||||||
#if defined(HAVE_LIBZ)
|
#if defined(HAVE_LIBZ)
|
||||||
|
int flags = 0;
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
unsigned wl = fl_utf8towc(fname, strlen(fname), NULL, 0) + 1;
|
flags = _O_BINARY;
|
||||||
wchar_t *wc = new wchar_t[wl];
|
# endif
|
||||||
fl_utf8towc(fname, strlen(fname), wc, wl);
|
int fd = fl_open(fname, flags);
|
||||||
gzFile gzf = gzopen_w(wc, "r");
|
|
||||||
delete[] wc;
|
|
||||||
return gzf;
|
|
||||||
# else
|
|
||||||
int fd = fl_open(fname, 0);
|
|
||||||
if (fd < 0) return NULL;
|
if (fd < 0) return NULL;
|
||||||
return gzdopen(fd, "r");
|
return gzdopen(fd, "r");
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // HAVE_LIBZ
|
#endif // HAVE_LIBZ
|
||||||
|
Loading…
Reference in New Issue
Block a user