]> granicus.if.org Git - php/commitdiff
fix unlink - make sure it actually erases the file
authorGreg Beaver <cellog@php.net>
Sun, 7 Jan 2007 19:05:12 +0000 (19:05 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 7 Jan 2007 19:05:12 +0000 (19:05 +0000)
ext/phar/phar.c

index 2474adc5e37c839def93d09dd70eff9f78349c89..fa7a426e4cad7bf0dba44761fcc373ca03dd3c99 100644 (file)
@@ -1095,7 +1095,7 @@ php_stream_wrapper php_stream_phar_wrapper =  {
  */
 static int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32 TSRMLS_DC) /* {{{ */
 {
-       unsigned int crc = ~0;
+       php_uint32 crc = ~0;
        int len = idata->internal_file->uncompressed_filesize;
        char c;
 
@@ -1517,7 +1517,7 @@ static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */
        off_t manifest_ftell, bufsize;
        long offset;
        php_uint32 copy, loc, new_manifest_count;
-       unsigned int newcrc32;
+       php_uint32 newcrc32;
        php_stream *file, *newfile, *compressedfile;
        php_stream_filter *filter;
 
@@ -2198,6 +2198,7 @@ static int phar_unlink(php_stream_wrapper *wrapper, char *url, int options, php_
        php_url *resource;
        char *internal_file;
        phar_entry_data *idata;
+       php_stream *fpf;
        
        resource = php_url_parse(url);
 
@@ -2240,6 +2241,10 @@ static int phar_unlink(php_stream_wrapper *wrapper, char *url, int options, php_
                }
        }
        idata->internal_file->flags |= PHAR_ENT_DELETED;
+       /* we need to "flush" the stream to save the newly deleted file on disk */
+       fpf = php_stream_alloc(&phar_ops, idata, NULL, "wb");
+       phar_flush(fpf TSRMLS_CC);
+       php_stream_close(fpf);
        efree(idata);
        efree(internal_file);
        php_url_free(resource);