From: Pierre Joye Date: Sat, 24 Feb 2007 18:59:37 +0000 (+0000) Subject: - merge from pecl: Force binary mode on windows X-Git-Tag: RELEASE_1_0_1~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c7d417e50e748ab807a58e1be88be9ff36343f7e;p=php - merge from pecl: Force binary mode on windows --- diff --git a/ext/zip/lib/zip_close.c b/ext/zip/lib/zip_close.c index 43da1a0722..bd6b59dcfa 100644 --- a/ext/zip/lib/zip_close.c +++ b/ext/zip/lib/zip_close.c @@ -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 **); - - 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; diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c index f3f4c11bde..2570641463 100644 --- a/ext/zip/lib/zip_open.c +++ b/ext/zip/lib/zip_open.c @@ -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); 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;