]> granicus.if.org Git - php/commitdiff
- merge from pecl: Force binary mode on windows
authorPierre Joye <pajoye@php.net>
Sat, 24 Feb 2007 18:59:37 +0000 (18:59 +0000)
committerPierre Joye <pajoye@php.net>
Sat, 24 Feb 2007 18:59:37 +0000 (18:59 +0000)
ext/zip/lib/zip_close.c
ext/zip/lib/zip_open.c
ext/zip/lib/zip_source_file.c

index 43da1a07222217b6041cdd8a1fd08e26212bf828..bd6b59dcfa016b70ec97f07c7192afcaeb302b53 100644 (file)
@@ -56,8 +56,6 @@ static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *);
 static int _zip_changed(struct zip *, int *);
 static char *_zip_create_temp_output(struct zip *, FILE **);
 
-\f
-
 int
 zip_close(struct zip *za)
 {
@@ -550,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;
index f3f4c11bdec77741dbc5b390b47e21c7cba04523..25706414637464ae4b95aeb9f1356bd16b7ece57 100644 (file)
@@ -100,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) {
@@ -108,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);
index f06b32fec61e418e9a220e736ff2e994a9b617cf..d635da3421c0424d1829acfe34815d30f2a8834b 100644 (file)
@@ -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;