From 5f8256cfc1f314d7e9c04c6459a7f0c611cf9eb9 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Tue, 30 Jan 2007 20:58:14 +0000 Subject: [PATCH] - Update TODO - Add Phar::isFlushing() - Improve test --- ext/phar/TODO | 8 ++++-- ext/phar/phar_object.c | 28 +++++++++++++------ ext/phar/tests/phar_begin_setstub_commit.phpt | 6 ++++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ext/phar/TODO b/ext/phar/TODO index 6161f84e852..878a2b44776 100644 --- a/ext/phar/TODO +++ b/ext/phar/TODO @@ -28,8 +28,6 @@ Version 1.0.0 X Phar archive metadata Phar::setMetaData($metadata) Phar::getMetaData() [Greg] X support rename() in stream wrapper [Greg] * update docs to reflect changes in error handling - * update docs to add setStub(), make note about not using it within begin()/commit() - ? have setStub() throw an exception if used between begin()/commit() [erase if no] * fix 011.phpt, 029.phpt for uncaught exceptions causing bad cleanup Version 1.1.0 @@ -39,3 +37,9 @@ Version 1.1.0 * implement GPG signing * ability to match files containing a metadata key opendir('phar://a.phar/?mime-type=image/jpeg') or foreach ($p->match('mime-type', 'image/jpeg') as $file) + * Phar::copy($from, $to); + * Phar::delete($what) + * Phar::buildFromIterator($filename, Iterator $it, array $addinfo = null); + $addinfo = array('alias','flags','metadata','stub'...) + * Layout: Option to compress all content rather than single files. + That excludes stub and anifest haeder. diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index e32f6daec8c..758b64c73f4 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -225,6 +225,17 @@ PHP_METHOD(Phar, begin) } /* }}} */ +/* {{{ proto bool Phar::isFlushing() + * Returns whether write operations are flushing to disk immediately + */ +PHP_METHOD(Phar, isFlushing) +{ + PHAR_ARCHIVE_OBJECT(); + + RETURN_BOOL(!phar_obj->arc.archive->donotflush); +} +/* }}} */ + /* {{{ proto bool Phar::commit() * Save the contents of a modified phar */ @@ -1084,23 +1095,24 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PRIVATE) #else PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PUBLIC) + PHP_ME(Phar, begin, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, commit, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, compressAllFilesGZ, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, compressAllFilesBZIP2, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, count, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, getMetadata, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, getModified, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, getSignature, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, getStub, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC) PHP_ME(Phar, getVersion, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, begin, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, compressAllFilesGZ, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, compressAllFilesBZIP2, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, uncompressAllFiles, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phar, commit, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, isFlushing, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Phar, setMetadata, arginfo_entry_setMetadata, ZEND_ACC_PUBLIC) + PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC) PHP_ME(Phar, offsetUnset, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC) - PHP_ME(Phar, getMetadata, NULL, 0) - PHP_ME(Phar, setMetadata, arginfo_entry_setMetadata, 0) + PHP_ME(Phar, uncompressAllFiles, NULL, ZEND_ACC_PUBLIC) #endif /* static member functions */ PHP_ME(Phar, apiVersion, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL) diff --git a/ext/phar/tests/phar_begin_setstub_commit.phpt b/ext/phar/tests/phar_begin_setstub_commit.phpt index 9f815da319b..ed9c12b6384 100755 --- a/ext/phar/tests/phar_begin_setstub_commit.phpt +++ b/ext/phar/tests/phar_begin_setstub_commit.phpt @@ -9,7 +9,9 @@ phar.readonly=0 getStub()); +var_dump($p->isFlushing()); $p->begin(); +var_dump($p->isFlushing()); $p['a.php'] = 'setStub(''); include 'phar://brandnewphar.phar/a.php'; @@ -20,6 +22,7 @@ include 'phar://brandnewphar.phar/b.php'; var_dump($p->getStub()); $p->commit(); echo "===COMMIT===\n"; +var_dump($p->isFlushing()); include 'phar://brandnewphar.phar/a.php'; include 'phar://brandnewphar.phar/b.php'; var_dump($p->getStub()); @@ -30,11 +33,14 @@ var_dump($p->getStub()); unlink(dirname(__FILE__) . '/brandnewphar.phar'); ?> --EXPECT-- +bool(true) +bool(false) string(5) "Hello" string(82) "" string(5) "World" string(83) "" ===COMMIT=== +bool(true) string(5) "Hello" string(5) "World" string(83) ""