summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/zip/lib/zip_close.c3
-rw-r--r--ext/zip/lib/zip_open.c9
-rw-r--r--ext/zip/lib/zip_source_file.c4
3 files changed, 11 insertions, 5 deletions
diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c
index 6881d1e42b..f077b8df05 100644
--- a/ext/zip/lib/zip_close.c
+++ b/ext/zip/lib/zip_close.c
@@ -548,6 +548,9 @@ _zip_create_temp_output(struct zip *za, FILE **outp)
free(temp);
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(tfp), _O_BINARY );
+#endif
*outp = tfp;
return temp;
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c
index c8d45146db..f2f3cc3bc4 100644
--- a/ext/zip/lib/zip_open.c
+++ b/ext/zip/lib/zip_open.c
@@ -75,10 +75,6 @@ zip_open(const char *fn, int flags, int *zep)
return NULL;
}
-#ifdef PHP_WIN32
- _fmode = _O_BINARY;
-#endif
-
if (flags & ZIP_OVERWRITE || stat(fn, &st) != 0) {
if ((flags & ZIP_CREATE) || (flags & ZIP_OVERWRITE)) {
if ((za=_zip_new(&error)) == NULL) {
@@ -104,7 +100,6 @@ zip_open(const char *fn, int flags, int *zep)
return NULL;
}
-
/* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL,
just like open() */
if ((fp=fopen(fn, "rb")) == NULL) {
@@ -112,6 +107,10 @@ zip_open(const char *fn, int flags, int *zep)
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(fp), _O_BINARY );
+#endif
+
clearerr(fp);
fseek(fp, 0, SEEK_END);
len = ftell(fp);
diff --git a/ext/zip/lib/zip_source_file.c b/ext/zip/lib/zip_source_file.c
index f06b32fec6..d635da3421 100644
--- a/ext/zip/lib/zip_source_file.c
+++ b/ext/zip/lib/zip_source_file.c
@@ -62,6 +62,10 @@ zip_source_file(struct zip *za, const char *fname, off_t start, off_t len)
return NULL;
}
+#ifdef PHP_WIN32
+ _setmode(_fileno(fp), _O_BINARY );
+#endif
+
if ((zs=zip_source_filep(za, fp, start, len)) == NULL) {
fclose(fp);
return NULL;