Re: cvs: pecl /phar phar_object.c /phar/tests phar_oo_compressallbz2.phpt phar_oo_compressallgz.phpt phar_oo_getcontents.phpt
phar_oo_getcontentsgz.phpt phar_oo_getmodified.phpt phar_oo_uncompressall.phpt
| From: | Lars Strojny | Date: | Thu, 10 Apr 2008 12:55:08 +0000 |
| Subject: | Re: cvs: pecl /phar phar_object.c /phar/tests phar_oo_compressallbz2.phpt phar_oo_compressallgz.phpt phar_oo_getcontents.phpt phar_oo_getcontentsgz.phpt phar_oo_getmodified.phpt phar_oo_uncompressall.phpt |
||
| References: | 1 | Groups: | php.pecl.cvs |
| Request: | Send a blank email to pecl-cvs+get-10332@lists.php.net to get a copy of this message | ||
Hi Gregory,
helly agreed to add SplFileInfo::getContent()/setContent() to
SplFileInfo. As far as I know, it was getContent() not getContents(). It
seems really important to have that consistent.
cu, Lars
Am Mittwoch, den 09.04.2008, 18:12 +0000 schrieb Greg Beaver:
> cellog Wed Apr 9 18:12:41 2008 UTC
>
> Added files:
> /pecl/phar/tests phar_oo_getcontents.phpt
> phar_oo_getcontentsgz.phpt
>
> Modified files:
> /pecl/phar phar_object.c
> /pecl/phar/tests phar_oo_compressallbz2.phpt
> phar_oo_compressallgz.phpt
> phar_oo_getmodified.phpt
> phar_oo_uncompressall.phpt
> Log:
> add PharFileInfo->getContents() to retrieve file contents
> [DOC]
>
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/phar_object.c?r1=1.194&r2=1.195&diff_format=u
> Index: pecl/phar/phar_object.c
> diff -u pecl/phar/phar_object.c:1.194 pecl/phar/phar_object.c:1.195
> --- pecl/phar/phar_object.c:1.194 Mon Mar 24 03:01:29 2008
> +++ pecl/phar/phar_object.c Wed Apr 9 18:12:40 2008
> @@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: phar_object.c,v 1.194 2008/03/24 03:01:29 cellog Exp $ */
> +/* $Id: phar_object.c,v 1.195 2008/04/09 18:12:40 cellog Exp $ */
>
> #include "phar_internal.h"
> #include "func_interceptors.h"
> @@ -3466,6 +3466,37 @@
> }
> /* }}} */
>
> +/* {{{ proto string PharFileInfo::getContents()
> + * return the complete file contents of the entry (like file_get_contents)
> + */
> +PHP_METHOD(PharFileInfo, getContents)
> +{
> + char *error;
> + php_stream *fp;
> + PHAR_ENTRY_OBJECT();
> +
> + if (entry_obj->ent.entry->is_dir) {
> + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
> + "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a
> directory", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
> + return;
> + }
> + if (SUCCESS != phar_open_entry_fp(entry_obj->ent.entry, &error TSRMLS_CC)) {
> + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
> + "Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\":
> %s", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname, error);
> + efree(error);
> + return;
> + }
> + if (!(fp = phar_get_efp(entry_obj->ent.entry TSRMLS_CC))) {
> + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
> + "Phar error: Cannot retrieve contents of \"%s\" in phar
> \"%s\"", entry_obj->ent.entry->filename,
> entry_obj->ent.entry->phar->fname);
> + return;
> + }
> + phar_seek_efp(entry_obj->ent.entry, 0, SEEK_SET, 0 TSRMLS_CC);
> + Z_TYPE_P(return_value) = IS_STRING;
> + Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)),
> entry_obj->ent.entry->uncompressed_filesize, 0);
> +}
> +/* }}} */
> +
> /* {{{ proto int PharFileInfo::setCompressedGZ()
> * Instructs the Phar class to compress the current file using zlib
> */
> @@ -3822,6 +3853,7 @@
> PHP_ME(PharFileInfo, __destruct, NULL, 0)
> PHP_ME(PharFileInfo, chmod, arginfo_entry_chmod, 0)
> PHP_ME(PharFileInfo, delMetadata, NULL, 0)
> + PHP_ME(PharFileInfo, getContents, NULL, 0)
> PHP_ME(PharFileInfo, getCompressedSize, NULL, 0)
> PHP_ME(PharFileInfo, getCRC32, NULL, 0)
> PHP_ME(PharFileInfo, getMetadata, NULL, 0)
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_compressallbz2.phpt?r1=1.4&r2=1.5&diff_format=u
> Index: pecl/phar/tests/phar_oo_compressallbz2.phpt
> diff -u pecl/phar/tests/phar_oo_compressallbz2.phpt:1.4
> pecl/phar/tests/phar_oo_compressallbz2.phpt:1.5
> --- pecl/phar/tests/phar_oo_compressallbz2.phpt:1.4 Sun Mar 9 04:46:15 2008
> +++ pecl/phar/tests/phar_oo_compressallbz2.phpt Wed Apr 9 18:12:40 2008
> @@ -45,6 +45,7 @@
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar');
> +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> ?>
> --EXPECTF--
> string(1) "a"
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_compressallgz.phpt?r1=1.4&r2=1.5&diff_format=u
> Index: pecl/phar/tests/phar_oo_compressallgz.phpt
> diff -u pecl/phar/tests/phar_oo_compressallgz.phpt:1.4
> pecl/phar/tests/phar_oo_compressallgz.phpt:1.5
> --- pecl/phar/tests/phar_oo_compressallgz.phpt:1.4 Sun Mar 9 04:46:15 2008
> +++ pecl/phar/tests/phar_oo_compressallgz.phpt Wed Apr 9 18:12:40 2008
> @@ -45,6 +45,7 @@
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar');
> +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> ?>
> --EXPECTF--
> string(1) "a"
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_getmodified.phpt?r1=1.4&r2=1.5&diff_format=u
> Index: pecl/phar/tests/phar_oo_getmodified.phpt
> diff -u pecl/phar/tests/phar_oo_getmodified.phpt:1.4
> pecl/phar/tests/phar_oo_getmodified.phpt:1.5
> --- pecl/phar/tests/phar_oo_getmodified.phpt:1.4 Sun Mar 9 04:46:15 2008
> +++ pecl/phar/tests/phar_oo_getmodified.phpt Wed Apr 9 18:12:40 2008
> @@ -28,6 +28,7 @@
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar');
> +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> ?>
> --EXPECTF--
> bool(false)
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_uncompressall.phpt?r1=1.4&r2=1.5&diff_format=u
> Index: pecl/phar/tests/phar_oo_uncompressall.phpt
> diff -u pecl/phar/tests/phar_oo_uncompressall.phpt:1.4
> pecl/phar/tests/phar_oo_uncompressall.phpt:1.5
> --- pecl/phar/tests/phar_oo_uncompressall.phpt:1.4 Sun Mar 9 04:46:15 2008
> +++ pecl/phar/tests/phar_oo_uncompressall.phpt Wed Apr 9 18:12:40 2008
> @@ -53,6 +53,7 @@
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar');
> +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> ?>
> --EXPECTF--
> string(1) "a"
>
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_getcontents.phpt?view=markup&rev=1.1
> Index: pecl/phar/tests/phar_oo_getcontents.phpt
> +++ pecl/phar/tests/phar_oo_getcontents.phpt
> --TEST--
> Phar object: getContents()
> --SKIPIF--
> <?php if (!extension_loaded("phar")) die("skip"); ?>
> <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
> --INI--
> phar.readonly=0
> --FILE--
> <?php
> $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') .
> '.phar.php';
>
> $phar = new Phar($fname);
> $phar['a'] = 'file contents
> this works';
> echo $phar['a']->getContents() . "\n";
> ?>
> ===DONE===
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> __halt_compiler();
> ?>
> --EXPECT--
> file contents
> this works
> ===DONE===
>
> http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_oo_getcontentsgz.phpt?view=markup&rev=1.1Jê
> ŽuÕÆ
Ö¹q¢Ø%+
> Index: pecl/phar/tests/phar_oo_getcontentsgz.phpt
> +++ pecl/phar/tests/phar_oo_getcontentsgz.phpt
> --TEST--
> Phar object: getContents() (verify it works with compression)
> --SKIPIF--
> <?php if (!extension_loaded("phar")) die("skip"); ?>
> <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
> <?php if (!extension_loaded("zlib")) die("skip zlib not available");
> ?>
> --INI--
> phar.readonly=0
> --FILE--
> <?php
> $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') .
> '.phar.php';
> $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') .
> '.2.phar.php';
>
> $phar = new Phar($fname);
> $phar['a'] = 'file contents
> this works';
> $phar['a']->setCompressedGZ();
> copy($fname, $fname2);
> $phar2 = new Phar($fname2);
> var_dump($phar2['a']->isCompressed());
> echo $phar2['a']->getContents() . "\n";
> ?>
> ===DONE===
> --CLEAN--
> <?php
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.phar.php');
> unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
> '.2.phar.php');
> __halt_compiler();
> ?>
> --EXPECT--
> bool(true)
> file contents
> this works
> ===DONE===
>
>
Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc
Attachment: [application/pgp-signature] Dies ist ein digital signierter Nachrichtenteil signature.asc