]> git.lizzy.rs Git - zlib.git/commitdiff
Add gzopen_w() in Windows for wide character path names.
authorMark Adler <madler@alumni.caltech.edu>
Sat, 17 Mar 2012 03:53:09 +0000 (20:53 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sat, 17 Mar 2012 03:53:09 +0000 (20:53 -0700)
contrib/vstudio/vc10/zlibvc.def
contrib/vstudio/vc9/zlibvc.def
gzguts.h
gzlib.c
win32/zlib.def
zconf.h
zconf.h.cmakein
zconf.h.in
zlib.h

index d39a1d246410c0f75a7de6305ba87de3cc081e08..f0bf0351c2f7fe0a476ffda9a0aeaccd1c62b504 100644 (file)
@@ -135,3 +135,6 @@ EXPORTS
         gzflags                                 @162\r
         inflateResetKeep                        @163\r
         deflateResetKeep                        @164\r
+
+; zlib1 v1.2.7 added:
+        gzopen_w                                @165
index 0c6d77428ac4863b2a21afa87f5b08bf2c9a59bf..03a45dc418850b96518e1c99e85e2938e7ee9ecf 100644 (file)
@@ -134,4 +134,7 @@ EXPORTS
         gzgetc_                                 @161\r
         gzflags                                 @162\r
         inflateResetKeep                        @163\r
-       deflateResetKeep                        @164
+        deflateResetKeep                        @164
+
+; zlib1 v1.2.7 added:
+        gzopen_w                                @165
index 0ccc9a6787590e5e73f0ddaecc91c0776ff971b9..13e81791ef3f2309aeaae778e4ad4cc158bdca9e 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
@@ -27,7 +27,7 @@
 #endif
 #include <fcntl.h>
 
-#if defined(__TURBOC__) || defined(_MSC_VER)
+#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
 #  include <io.h>
 #endif
 
diff --git a/gzlib.c b/gzlib.c
index c35a6de311f1e9317631f12a2bd9a5e0a6f7fc4d..e90b6adb089bfb472cd195bbbe55d93eb765ca63 100644 (file)
--- a/gzlib.c
+++ b/gzlib.c
@@ -17,7 +17,7 @@
 
 /* Local functions */
 local void gz_reset OF((gz_statep));
-local gzFile gz_open OF((const char *, int, const char *));
+local gzFile gz_open OF((const void *, int, const char *));
 
 #if defined UNDER_CE
 
@@ -89,11 +89,12 @@ local void gz_reset(state)
 
 /* Open a gzip file either by name or file descriptor. */
 local gzFile gz_open(path, fd, mode)
-    const char *path;
+    const void *path;
     int fd;
     const char *mode;
 {
     gz_statep state;
+    int oflag;
 #ifdef O_CLOEXEC
     int cloexec = 0;
 #endif
@@ -191,28 +192,33 @@ local gzFile gz_open(path, fd, mode)
     }
     strcpy(state->path, path);
 
-    /* open the file with the appropriate mode (or just use fd) */
-    state->fd = fd != -1 ? fd :
-        open(path,
+    /* compute the flags for open() */
+    oflag =
 #ifdef O_LARGEFILE
-            O_LARGEFILE |
+        O_LARGEFILE |
 #endif
 #ifdef O_BINARY
-            O_BINARY |
+        O_BINARY |
 #endif
 #ifdef O_CLOEXEC
-            (cloexec ? O_CLOEXEC : 0) |
+        (cloexec ? O_CLOEXEC : 0) |
 #endif
-            (state->mode == GZ_READ ?
-                O_RDONLY :
-                (O_WRONLY | O_CREAT |
+        (state->mode == GZ_READ ?
+         O_RDONLY :
+         (O_WRONLY | O_CREAT |
 #ifdef O_EXCL
-                 (exclusive ? O_EXCL : 0) |
+          (exclusive ? O_EXCL : 0) |
+#endif
+          (state->mode == GZ_WRITE ?
+           O_TRUNC :
+           O_APPEND)));
+
+    /* open the file with the appropriate flags (or just use fd) */
+    state->fd = fd > -1 ? fd : (
+#ifdef _WIN32
+        fd == -2 ? _wopen(path, oflag, 0666) :
 #endif
-                 (state->mode == GZ_WRITE ?
-                    O_TRUNC :
-                    O_APPEND))),
-            0666);
+        open(path, oflag, 0666));
     if (state->fd == -1) {
         free(state->path);
         free(state);
@@ -266,6 +272,16 @@ gzFile ZEXPORT gzdopen(fd, mode)
     return gz;
 }
 
+/* -- see zlib.h -- */
+#ifdef _WIN32
+gzFile ZEXPORT gzopen_w(path, mode)
+    const w_char *path;
+    const char *mode;
+{
+    return gz_open(path, -2, mode);
+}
+#endif
+
 /* -- see zlib.h -- */
 int ZEXPORT gzbuffer(file, size)
     gzFile file;
index a2a2081c3f5fe43ddd9fb75b3d6780ae86d7fd11..04896150e4b7e41a9156e44590835894d2dfc2a3 100644 (file)
@@ -74,10 +74,11 @@ EXPORTS
     inflateInit_
     inflateInit2_
     inflateBackInit_
+    gzgetc_
     zError
     inflateSyncPoint
     get_crc_table
     inflateUndermine
     inflateResetKeep
     deflateResetKeep
-    gzgetc_
+    gzopen_w
diff --git a/zconf.h b/zconf.h
index af35c382d3b03c754aae34e42bcfc8240431691a..f9a5fa7d67c5e7e004a8d36f757306e52f16ce90 100644 (file)
--- a/zconf.h
+++ b/zconf.h
@@ -73,6 +73,9 @@
 #    define gzoffset64            z_gzoffset64
 #    define gzopen                z_gzopen
 #    define gzopen64              z_gzopen64
+#    ifdef _WIN32
+#      define gzopen_w              z_gzopen_w
+#    endif
 #    define gzprintf              z_gzprintf
 #    define gzputc                z_gzputc
 #    define gzputs                z_gzputs
index 81a7b7aa520dff0a9660185f9a1c7c3dcad482a8..66368adf9d5cee80ba6d034321b0699e29d42e79 100644 (file)
@@ -75,6 +75,9 @@
 #    define gzoffset64            z_gzoffset64
 #    define gzopen                z_gzopen
 #    define gzopen64              z_gzopen64
+#    ifdef _WIN32
+#      define gzopen_w              z_gzopen_w
+#    endif
 #    define gzprintf              z_gzprintf
 #    define gzputc                z_gzputc
 #    define gzputs                z_gzputs
index af35c382d3b03c754aae34e42bcfc8240431691a..f9a5fa7d67c5e7e004a8d36f757306e52f16ce90 100644 (file)
@@ -73,6 +73,9 @@
 #    define gzoffset64            z_gzoffset64
 #    define gzopen                z_gzopen
 #    define gzopen64              z_gzopen64
+#    ifdef _WIN32
+#      define gzopen_w              z_gzopen_w
+#    endif
 #    define gzprintf              z_gzprintf
 #    define gzputc                z_gzputc
 #    define gzputs                z_gzputs
diff --git a/zlib.h b/zlib.h
index a569b002a803abef628cf372a7bba0ffef1d7f93..361d72f5d83692b105ce550364d1640167be7920 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1732,6 +1732,10 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
 ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
 ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
 ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
+#if defined(_WIN32) && !defined(Z_SOLO)
+ZEXTERN gzFile         ZEXPORT gzopen_w OF((const w_char *path,
+                                            const char *mode));
+#endif
 
 #ifdef __cplusplus
 }