From d00fb8b360e5ef776dacc97301be3affe91dfb22 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Fri, 2 Jan 2009 00:07:57 +0000 Subject: - MFB: restore overwrite feature (regression introduced in 5.2.8) --- ext/zip/lib/zip_open.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/zip/lib/zip_open.c') diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c index 10c5e1e6d8..cd78281790 100644 --- a/ext/zip/lib/zip_open.c +++ b/ext/zip/lib/zip_open.c @@ -65,10 +65,14 @@ zip_open(const char *fn, int flags, int *zep) struct zip_cdir *cdir; int i; off_t len; - + + switch (_zip_file_exists(fn, flags, zep)) { case -1: - return NULL; + if (!(flags & ZIP_OVERWRITE)) { + return NULL; + } + case 0: return _zip_allocate_new(fn, zep); default: @@ -440,7 +444,7 @@ _zip_file_exists(const char *fn, int flags, int *zep) } if (stat(fn, &st) != 0) { - if (flags & ZIP_CREATE) + if (flags & ZIP_CREATE || flags & ZIP_OVERWRITE) return 0; else { set_error(zep, NULL, ZIP_ER_OPEN); -- cgit v1.2.1