cellog          Sat Oct 11 22:12:07 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/phar/tests/tar links6.phpt 

  Modified files:              
    /php-src/ext/phar   stream.c util.c 
  Log:
  fix reading links from streams (works with PharFileInfo->getContent())
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/stream.c?r1=1.27.2.19&r2=1.27.2.20&diff_format=u
Index: php-src/ext/phar/stream.c
diff -u php-src/ext/phar/stream.c:1.27.2.19 php-src/ext/phar/stream.c:1.27.2.20
--- php-src/ext/phar/stream.c:1.27.2.19 Fri Sep 26 23:34:57 2008
+++ php-src/ext/phar/stream.c   Sat Oct 11 22:12:06 2008
@@ -359,8 +359,15 @@
 {
        phar_entry_data *data = (phar_entry_data *)stream->abstract;
        size_t got;
+       phar_entry_info *entry;
+
+       if (data->internal_file->link) {
+               entry = phar_get_link_source(data->internal_file TSRMLS_CC);
+       } else {
+               entry = data->internal_file;
+       }
 
-       if (data->internal_file->is_deleted) {
+       if (entry->is_deleted) {
                stream->eof = 1;
                return 0;
        }
@@ -368,9 +375,9 @@
        /* use our proxy position */
        php_stream_seek(data->fp, data->position + data->zero, SEEK_SET);
 
-       got = php_stream_read(data->fp, buf, MIN(count, 
data->internal_file->uncompressed_filesize - data->position));
+       got = php_stream_read(data->fp, buf, MIN(count, 
entry->uncompressed_filesize - data->position));
        data->position = php_stream_tell(data->fp) - data->zero;
-       stream->eof = (data->position == (off_t) 
data->internal_file->uncompressed_filesize);
+       stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
 
        return got;
 }
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/util.c?r1=1.55.2.36&r2=1.55.2.37&diff_format=u
Index: php-src/ext/phar/util.c
diff -u php-src/ext/phar/util.c:1.55.2.36 php-src/ext/phar/util.c:1.55.2.37
--- php-src/ext/phar/util.c:1.55.2.36   Thu Oct  9 00:50:46 2008
+++ php-src/ext/phar/util.c     Sat Oct 11 22:12:07 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: util.c,v 1.55.2.36 2008/10/09 00:50:46 cellog Exp $ */
+/* $Id: util.c,v 1.55.2.37 2008/10/11 22:12:07 cellog Exp $ */
 
 #include "phar_internal.h"
 
@@ -65,12 +65,13 @@
 phar_entry_info *phar_get_link_source(phar_entry_info *entry TSRMLS_DC) /* {{{ 
*/
 {
        phar_entry_info *link_entry;
-       char *link = phar_get_link_location(entry TSRMLS_CC);
+       char *link;
 
        if (!entry->link) {
                return entry;
        }
 
+       link = phar_get_link_location(entry TSRMLS_CC);
        if (SUCCESS == zend_hash_find(&(entry->phar->manifest), entry->link, 
strlen(entry->link), (void **)&link_entry) ||
                SUCCESS == zend_hash_find(&(entry->phar->manifest), link, 
strlen(link), (void **)&link_entry)) {
                if (link != entry->link) {
@@ -680,13 +681,13 @@
                        phar_seek_efp(entry, 0, SEEK_END, 0, 0 TSRMLS_CC);
                }
        } else {
-               if (entry->link) {
-                       efree(entry->link);
-                       entry->link = NULL;
-                       entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
-               }
-
                if (for_write) {
+                       if (entry->link) {
+                               efree(entry->link);
+                               entry->link = NULL;
+                               entry->tar_type = (entry->is_tar ? TAR_FILE : 
'\0');
+                       }
+
                        if (for_trunc) {
                                if (FAILURE == 
phar_create_writeable_entry(phar, entry, error TSRMLS_CC)) {
                                        return FAILURE;
@@ -711,7 +712,11 @@
        (*ret)->is_zip = entry->is_zip;
        (*ret)->is_tar = entry->is_tar;
        (*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC);
-       (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC);
+       if (entry->link) {
+               (*ret)->zero = phar_get_fp_offset(phar_get_link_source(entry 
TSRMLS_CC) TSRMLS_CC);
+       } else {
+               (*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC);
+       }
 
        if (!phar->is_persistent) {
                ++(entry->fp_refcount);

http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/tar/links6.phpt?view=markup&rev=1.1
Index: php-src/ext/phar/tests/tar/links6.phpt
+++ php-src/ext/phar/tests/tar/links6.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to