From 2bf5042d74b1ee1e81de966b3c1f4778c7b3e96b Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Fri, 25 Apr 2008 16:10:59 +0000 Subject: [PATCH] finish code coverage testing of phar_object.c (except for iterator building, which Steph is doing) and fix segfault in error message for directory getcontent if it is a temp directory --- ext/phar/tests/phar_oo_getcontents.phpt | 19 ++++++++++++++++--- ext/phar/util.c | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ext/phar/tests/phar_oo_getcontents.phpt b/ext/phar/tests/phar_oo_getcontents.phpt index 76b3e64713..e42bca46fc 100644 --- a/ext/phar/tests/phar_oo_getcontents.phpt +++ b/ext/phar/tests/phar_oo_getcontents.phpt @@ -10,9 +10,20 @@ phar.readonly=0 $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; $phar = new Phar($fname); -$phar['a'] = 'file contents +$phar['a/b'] = 'file contents this works'; -echo $phar['a']->getContent() . "\n"; +$phar->addEmptyDir('hi'); +echo $phar['a/b']->getContent() . "\n"; +try { +echo $phar['a']->getContent(), "\n"; +} catch (Exception $e) { +echo $e->getMessage(), "\n"; +} +try { +echo $phar['hi']->getContent(), "\n"; +} catch (Exception $e) { +echo $e->getMessage(), "\n"; +} ?> ===DONE=== --CLEAN-- @@ -20,7 +31,9 @@ echo $phar['a']->getContent() . "\n"; unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); __halt_compiler(); ?> ---EXPECT-- +--EXPECTF-- file contents this works +Phar error: Cannot retrieve contents, "a" in phar "%sphar_oo_getcontents.phar.php" is a directory +Phar error: Cannot retrieve contents, "hi" in phar "%sphar_oo_getcontents.phar.php" is a directory ===DONE=== \ No newline at end of file diff --git a/ext/phar/util.c b/ext/phar/util.c index 16065b6339..82321a1c0b 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1228,6 +1228,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in entry->is_temp_dir = entry->is_dir = 1; entry->filename = (char *) estrndup(path, path_len + 1); entry->filename_len = path_len; + entry->phar = phar; return entry; } } -- 2.50.1