diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2012-03-16 20:53:09 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2012-03-16 20:53:09 -0700 |
| commit | dbe0bed739c26a2c36319794108cb87ad77c5469 (patch) | |
| tree | d09f1697ce762b88f7a2d1cff1969fb9ecee09d3 | |
| parent | a3881cc745729cde05d921b3750e2d56889b5d26 (diff) | |
| download | zlib-dbe0bed739c26a2c36319794108cb87ad77c5469.tar.gz zlib-dbe0bed739c26a2c36319794108cb87ad77c5469.tar.bz2 zlib-dbe0bed739c26a2c36319794108cb87ad77c5469.zip | |
Add gzopen_w() in Windows for wide character path names.
| -rw-r--r-- | contrib/vstudio/vc10/zlibvc.def | 3 | ||||
| -rw-r--r-- | contrib/vstudio/vc9/zlibvc.def | 5 | ||||
| -rw-r--r-- | gzguts.h | 2 | ||||
| -rw-r--r-- | gzlib.c | 48 | ||||
| -rw-r--r-- | win32/zlib.def | 3 | ||||
| -rw-r--r-- | zconf.h | 3 | ||||
| -rw-r--r-- | zconf.h.cmakein | 3 | ||||
| -rw-r--r-- | zconf.h.in | 3 | ||||
| -rw-r--r-- | zlib.h | 4 |
9 files changed, 55 insertions, 19 deletions
diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def index d39a1d2..f0bf035 100644 --- a/contrib/vstudio/vc10/zlibvc.def +++ b/contrib/vstudio/vc10/zlibvc.def | |||
| @@ -135,3 +135,6 @@ EXPORTS | |||
| 135 | gzflags @162 | 135 | gzflags @162 |
| 136 | inflateResetKeep @163 | 136 | inflateResetKeep @163 |
| 137 | deflateResetKeep @164 | 137 | deflateResetKeep @164 |
| 138 | |||
| 139 | ; zlib1 v1.2.7 added: | ||
| 140 | gzopen_w @165 | ||
diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def index 0c6d774..03a45dc 100644 --- a/contrib/vstudio/vc9/zlibvc.def +++ b/contrib/vstudio/vc9/zlibvc.def | |||
| @@ -134,4 +134,7 @@ EXPORTS | |||
| 134 | gzgetc_ @161 | 134 | gzgetc_ @161 |
| 135 | gzflags @162 | 135 | gzflags @162 |
| 136 | inflateResetKeep @163 | 136 | inflateResetKeep @163 |
| 137 | deflateResetKeep @164 | 137 | deflateResetKeep @164 |
| 138 | |||
| 139 | ; zlib1 v1.2.7 added: | ||
| 140 | gzopen_w @165 | ||
| @@ -27,7 +27,7 @@ | |||
| 27 | #endif | 27 | #endif |
| 28 | #include <fcntl.h> | 28 | #include <fcntl.h> |
| 29 | 29 | ||
| 30 | #if defined(__TURBOC__) || defined(_MSC_VER) | 30 | #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) |
| 31 | # include <io.h> | 31 | # include <io.h> |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | /* Local functions */ | 18 | /* Local functions */ |
| 19 | local void gz_reset OF((gz_statep)); | 19 | local void gz_reset OF((gz_statep)); |
| 20 | local gzFile gz_open OF((const char *, int, const char *)); | 20 | local gzFile gz_open OF((const void *, int, const char *)); |
| 21 | 21 | ||
| 22 | #if defined UNDER_CE | 22 | #if defined UNDER_CE |
| 23 | 23 | ||
| @@ -89,11 +89,12 @@ local void gz_reset(state) | |||
| 89 | 89 | ||
| 90 | /* Open a gzip file either by name or file descriptor. */ | 90 | /* Open a gzip file either by name or file descriptor. */ |
| 91 | local gzFile gz_open(path, fd, mode) | 91 | local gzFile gz_open(path, fd, mode) |
| 92 | const char *path; | 92 | const void *path; |
| 93 | int fd; | 93 | int fd; |
| 94 | const char *mode; | 94 | const char *mode; |
| 95 | { | 95 | { |
| 96 | gz_statep state; | 96 | gz_statep state; |
| 97 | int oflag; | ||
| 97 | #ifdef O_CLOEXEC | 98 | #ifdef O_CLOEXEC |
| 98 | int cloexec = 0; | 99 | int cloexec = 0; |
| 99 | #endif | 100 | #endif |
| @@ -191,28 +192,33 @@ local gzFile gz_open(path, fd, mode) | |||
| 191 | } | 192 | } |
| 192 | strcpy(state->path, path); | 193 | strcpy(state->path, path); |
| 193 | 194 | ||
| 194 | /* open the file with the appropriate mode (or just use fd) */ | 195 | /* compute the flags for open() */ |
| 195 | state->fd = fd != -1 ? fd : | 196 | oflag = |
| 196 | open(path, | ||
| 197 | #ifdef O_LARGEFILE | 197 | #ifdef O_LARGEFILE |
| 198 | O_LARGEFILE | | 198 | O_LARGEFILE | |
| 199 | #endif | 199 | #endif |
| 200 | #ifdef O_BINARY | 200 | #ifdef O_BINARY |
| 201 | O_BINARY | | 201 | O_BINARY | |
| 202 | #endif | 202 | #endif |
| 203 | #ifdef O_CLOEXEC | 203 | #ifdef O_CLOEXEC |
| 204 | (cloexec ? O_CLOEXEC : 0) | | 204 | (cloexec ? O_CLOEXEC : 0) | |
| 205 | #endif | 205 | #endif |
| 206 | (state->mode == GZ_READ ? | 206 | (state->mode == GZ_READ ? |
| 207 | O_RDONLY : | 207 | O_RDONLY : |
| 208 | (O_WRONLY | O_CREAT | | 208 | (O_WRONLY | O_CREAT | |
| 209 | #ifdef O_EXCL | 209 | #ifdef O_EXCL |
| 210 | (exclusive ? O_EXCL : 0) | | 210 | (exclusive ? O_EXCL : 0) | |
| 211 | #endif | ||
| 212 | (state->mode == GZ_WRITE ? | ||
| 213 | O_TRUNC : | ||
| 214 | O_APPEND))); | ||
| 215 | |||
| 216 | /* open the file with the appropriate flags (or just use fd) */ | ||
| 217 | state->fd = fd > -1 ? fd : ( | ||
| 218 | #ifdef _WIN32 | ||
| 219 | fd == -2 ? _wopen(path, oflag, 0666) : | ||
| 211 | #endif | 220 | #endif |
| 212 | (state->mode == GZ_WRITE ? | 221 | open(path, oflag, 0666)); |
| 213 | O_TRUNC : | ||
| 214 | O_APPEND))), | ||
| 215 | 0666); | ||
| 216 | if (state->fd == -1) { | 222 | if (state->fd == -1) { |
| 217 | free(state->path); | 223 | free(state->path); |
| 218 | free(state); | 224 | free(state); |
| @@ -267,6 +273,16 @@ gzFile ZEXPORT gzdopen(fd, mode) | |||
| 267 | } | 273 | } |
| 268 | 274 | ||
| 269 | /* -- see zlib.h -- */ | 275 | /* -- see zlib.h -- */ |
| 276 | #ifdef _WIN32 | ||
| 277 | gzFile ZEXPORT gzopen_w(path, mode) | ||
| 278 | const w_char *path; | ||
| 279 | const char *mode; | ||
| 280 | { | ||
| 281 | return gz_open(path, -2, mode); | ||
| 282 | } | ||
| 283 | #endif | ||
| 284 | |||
| 285 | /* -- see zlib.h -- */ | ||
| 270 | int ZEXPORT gzbuffer(file, size) | 286 | int ZEXPORT gzbuffer(file, size) |
| 271 | gzFile file; | 287 | gzFile file; |
| 272 | unsigned size; | 288 | unsigned size; |
diff --git a/win32/zlib.def b/win32/zlib.def index a2a2081..0489615 100644 --- a/win32/zlib.def +++ b/win32/zlib.def | |||
| @@ -74,10 +74,11 @@ EXPORTS | |||
| 74 | inflateInit_ | 74 | inflateInit_ |
| 75 | inflateInit2_ | 75 | inflateInit2_ |
| 76 | inflateBackInit_ | 76 | inflateBackInit_ |
| 77 | gzgetc_ | ||
| 77 | zError | 78 | zError |
| 78 | inflateSyncPoint | 79 | inflateSyncPoint |
| 79 | get_crc_table | 80 | get_crc_table |
| 80 | inflateUndermine | 81 | inflateUndermine |
| 81 | inflateResetKeep | 82 | inflateResetKeep |
| 82 | deflateResetKeep | 83 | deflateResetKeep |
| 83 | gzgetc_ | 84 | gzopen_w |
| @@ -73,6 +73,9 @@ | |||
| 73 | # define gzoffset64 z_gzoffset64 | 73 | # define gzoffset64 z_gzoffset64 |
| 74 | # define gzopen z_gzopen | 74 | # define gzopen z_gzopen |
| 75 | # define gzopen64 z_gzopen64 | 75 | # define gzopen64 z_gzopen64 |
| 76 | # ifdef _WIN32 | ||
| 77 | # define gzopen_w z_gzopen_w | ||
| 78 | # endif | ||
| 76 | # define gzprintf z_gzprintf | 79 | # define gzprintf z_gzprintf |
| 77 | # define gzputc z_gzputc | 80 | # define gzputc z_gzputc |
| 78 | # define gzputs z_gzputs | 81 | # define gzputs z_gzputs |
diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 81a7b7a..66368ad 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein | |||
| @@ -75,6 +75,9 @@ | |||
| 75 | # define gzoffset64 z_gzoffset64 | 75 | # define gzoffset64 z_gzoffset64 |
| 76 | # define gzopen z_gzopen | 76 | # define gzopen z_gzopen |
| 77 | # define gzopen64 z_gzopen64 | 77 | # define gzopen64 z_gzopen64 |
| 78 | # ifdef _WIN32 | ||
| 79 | # define gzopen_w z_gzopen_w | ||
| 80 | # endif | ||
| 78 | # define gzprintf z_gzprintf | 81 | # define gzprintf z_gzprintf |
| 79 | # define gzputc z_gzputc | 82 | # define gzputc z_gzputc |
| 80 | # define gzputs z_gzputs | 83 | # define gzputs z_gzputs |
| @@ -73,6 +73,9 @@ | |||
| 73 | # define gzoffset64 z_gzoffset64 | 73 | # define gzoffset64 z_gzoffset64 |
| 74 | # define gzopen z_gzopen | 74 | # define gzopen z_gzopen |
| 75 | # define gzopen64 z_gzopen64 | 75 | # define gzopen64 z_gzopen64 |
| 76 | # ifdef _WIN32 | ||
| 77 | # define gzopen_w z_gzopen_w | ||
| 78 | # endif | ||
| 76 | # define gzprintf z_gzprintf | 79 | # define gzprintf z_gzprintf |
| 77 | # define gzputc z_gzputc | 80 | # define gzputc z_gzputc |
| 78 | # define gzputs z_gzputs | 81 | # define gzputs z_gzputs |
| @@ -1732,6 +1732,10 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); | |||
| 1732 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); | 1732 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); |
| 1733 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); | 1733 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); |
| 1734 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | 1734 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); |
| 1735 | #if defined(_WIN32) && !defined(Z_SOLO) | ||
| 1736 | ZEXTERN gzFile ZEXPORT gzopen_w OF((const w_char *path, | ||
| 1737 | const char *mode)); | ||
| 1738 | #endif | ||
| 1735 | 1739 | ||
| 1736 | #ifdef __cplusplus | 1740 | #ifdef __cplusplus |
| 1737 | } | 1741 | } |
