From 7b6b53b83d5b8869f1e0ee3d4171d8cfa5150a24 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sat, 27 Jan 2007 18:57:12 +0000 Subject: [PATCH] php_stream_truncate_set_size() is a noop with temp streams. so, we're going to use a brand new tempfile for truncation. ALL TESTS PASS NOW (finally) --- ext/phar/phar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/phar/phar.c b/ext/phar/phar.c index e436185410..22a523b68b 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -293,9 +293,9 @@ static int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len (*ret)->internal_file = entry; if (entry->fp) { /* make a copy */ - (*ret)->fp = entry->fp; if (for_trunc) { - php_stream_truncate_set_size(entry->fp, 0); + php_stream_close(entry->fp); + entry->fp = php_stream_fopen_tmpfile(); entry->is_modified = 1; phar->is_modified = 1; /* reset file size */ @@ -305,6 +305,7 @@ static int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len } else if (for_append) { php_stream_seek(entry->fp, 0, SEEK_END); } + (*ret)->fp = entry->fp; } else { (*ret)->fp = 0; if (for_write) { -- 2.40.0