cellog Wed Apr 9 19:23:30 2008 UTC
Added files:
/pecl/phar/tests addfuncs.phpt
Modified files:
/pecl/phar dirstream.c phar_object.c util.c
/pecl/phar/tests dir.phpt
/pecl/phar/tests/tar 033.phpt 033a.phpt dir.phpt
/pecl/phar/tests/zip 033.phpt 033a.phpt dir.phpt
Log:
add addFile/addFromString/addEmptyDir. API is identical to ext/zip
[DOC]
http://cvs.php.net/viewvc.cgi/pecl/phar/dirstream.c?r1=1.13&r2=1.14&diff_format=u
Index: pecl/phar/dirstream.c
diff -u pecl/phar/dirstream.c:1.13 pecl/phar/dirstream.c:1.14
--- pecl/phar/dirstream.c:1.13 Mon Mar 24 03:01:29 2008
+++ pecl/phar/dirstream.c Wed Apr 9 19:23:30 2008
@@ -471,7 +471,7 @@
return FAILURE;
}
- if ((e = phar_get_entry_info_dir(phar, resource->path + 1,
strlen(resource->path + 1), 1, &error TSRMLS_CC))) {
+ if ((e = phar_get_entry_info_dir(phar, resource->path + 1,
strlen(resource->path + 1), 2, &error TSRMLS_CC))) {
/* directory exists, or is a subdirectory of an existing file */
efree(e->filename);
efree(e);
@@ -485,6 +485,18 @@
php_url_free(resource);
return FAILURE;
}
+ if ((e = phar_get_entry_info_dir(phar, resource->path + 1,
strlen(resource->path + 1), 0, &error TSRMLS_CC))) {
+ /* entry exists as a file */
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar
error: cannot create directory \"%s\" in phar \"%s\", file already exists",
resource->path+1, resource->host);
+ php_url_free(resource);
+ return FAILURE;
+ }
+ if (error) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar
error: cannot create directory \"%s\" in phar \"%s\", %s", resource->path+1,
resource->host, error);
+ efree(error);
+ php_url_free(resource);
+ return FAILURE;
+ }
memset((void *) &entry, 0, sizeof(phar_entry_info));
@@ -582,7 +594,7 @@
return FAILURE;
}
- if (!(entry = phar_get_entry_info_dir(phar, resource->path + 1,
strlen(resource->path + 1), 1, &error TSRMLS_CC))) {
+ if (!(entry = phar_get_entry_info_dir(phar, resource->path + 1,
strlen(resource->path + 1), 2, &error TSRMLS_CC))) {
if (error) {
php_stream_wrapper_log_error(wrapper, options
TSRMLS_CC, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s",
resource->path+1, resource->host, error);
efree(error);
http://cvs.php.net/viewvc.cgi/pecl/phar/phar_object.c?r1=1.195&r2=1.196&diff_format=u
Index: pecl/phar/phar_object.c
diff -u pecl/phar/phar_object.c:1.195 pecl/phar/phar_object.c:1.196
--- pecl/phar/phar_object.c:1.195 Wed Apr 9 18:12:40 2008
+++ pecl/phar/phar_object.c Wed Apr 9 19:23:30 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.195 2008/04/09 18:12:40 cellog Exp $ */
+/* $Id: phar_object.c,v 1.196 2008/04/09 19:23:30 cellog Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -2827,7 +2827,7 @@
return;
}
- if (!phar_get_entry_info_dir(phar_obj->arc.archive, fname, fname_len,
2, &error TSRMLS_CC)) {
+ if (!phar_get_entry_info_dir(phar_obj->arc.archive, fname, fname_len,
1, &error TSRMLS_CC)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:"");
} else {
fname_len = spprintf(&fname, 0, "phar://%s/%s",
phar_obj->arc.archive->fname, fname);
@@ -2840,44 +2840,21 @@
}
/* }}} */
-/* {{{ proto int Phar::offsetSet(string entry, string value)
- * set the contents of an internal file to those of an external file
+/* {{{ add a file within the phar archive from a string or resource
*/
-PHP_METHOD(Phar, offsetSet)
+static void phar_add_file(phar_archive_data *phar, char *filename, int
filename_len, char *cont_str, int cont_len, zval *zresource TSRMLS_DC)
{
- char *fname, *cont_str = NULL, *error;
- int fname_len, cont_len;
- zval *zresource;
+ char *error;
long contents_len;
phar_entry_data *data;
php_stream *contents_file;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Write operations disabled by INI setting");
- return;
- }
-
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS()
TSRMLS_CC, "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &fname,
&fname_len, &cont_str, &cont_len) == FAILURE) {
- return;
- }
- if ((phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) &&
fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php",
sizeof(".phar/stub.php")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use
setStub", phar_obj->arc.archive->fname);
- return;
- }
-
- if ((phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) &&
fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt",
sizeof(".phar/alias.txt")-1)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use
setAlias", phar_obj->arc.archive->fname);
- return;
- }
- if (!(data =
phar_get_or_create_entry_data(phar_obj->arc.archive->fname,
phar_obj->arc.archive->fname_len, fname, fname_len, "w+b", 2, &error
TSRMLS_CC))) {
+ if (!(data = phar_get_or_create_entry_data(phar->fname,
phar->fname_len, filename, filename_len, "w+b", 0, &error TSRMLS_CC))) {
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Entry %s does not exist and cannot be created: %s", fname, error);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Entry %s does not exist and cannot be created: %s", filename,
error);
efree(error);
} else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Entry %s does not exist and cannot be created", fname);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Entry %s does not exist and cannot be created", filename);
}
return;
} else {
@@ -2888,12 +2865,12 @@
if (cont_str) {
contents_len = php_stream_write(data->fp,
cont_str, cont_len);
if (contents_len != cont_len) {
-
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s
could not be written to", fname);
+
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s
could not be written to", filename);
return;
}
} else {
if
(!(php_stream_from_zval_no_verify(contents_file, &zresource))) {
-
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s
could not be written to", fname);
+
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s
could not be written to", filename);
return;
}
contents_len =
php_stream_copy_to_stream(contents_file, data->fp, PHP_STREAM_COPY_ALL);
@@ -2901,7 +2878,7 @@
data->internal_file->compressed_filesize =
data->internal_file->uncompressed_filesize = contents_len;
}
phar_entry_delref(data TSRMLS_CC);
- phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0
TSRMLS_CC, error);
efree(error);
@@ -2910,6 +2887,69 @@
}
/* }}} */
+/* {{{ create a directory within the phar archive
+ */
+static void phar_mkdir(phar_archive_data *phar, char *dirname, int dirname_len
TSRMLS_DC)
+{
+ char *error;
+ phar_entry_data *data;
+
+ if (!(data = phar_get_or_create_entry_data(phar->fname,
phar->fname_len, dirname, dirname_len, "w+b", 2, &error TSRMLS_CC))) {
+ if (error) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Directory %s does not exist and cannot be created: %s", dirname,
error);
+ efree(error);
+ } else {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException,
0 TSRMLS_CC, "Directory %s does not exist and cannot be created", dirname);
+ }
+ return;
+ } else {
+ if (error) {
+ efree(error);
+ }
+ phar_entry_delref(data TSRMLS_CC);
+ phar_flush(phar, 0, 0, 0, &error TSRMLS_CC);
+ if (error) {
+ zend_throw_exception_ex(phar_ce_PharException, 0
TSRMLS_CC, error);
+ efree(error);
+ }
+ }
+}
+/* }}} */
+
+
+/* {{{ proto int Phar::offsetSet(string entry, string value)
+ * set the contents of an internal file to those of an external file
+ */
+PHP_METHOD(Phar, offsetSet)
+{
+ char *fname, *cont_str = NULL;
+ int fname_len, cont_len;
+ zval *zresource;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Write operations disabled by INI setting");
+ return;
+ }
+
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS()
TSRMLS_CC, "sr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &fname,
&fname_len, &cont_str, &cont_len) == FAILURE) {
+ return;
+ }
+
+ if ((phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) &&
fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php",
sizeof(".phar/stub.php")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use
setStub", phar_obj->arc.archive->fname);
+ return;
+ }
+
+ if ((phar_obj->arc.archive->is_tar || phar_obj->arc.archive->is_zip) &&
fname_len == sizeof(".phar/alias.txt")-1 && !memcmp(fname, ".phar/alias.txt",
sizeof(".phar/alias.txt")-1)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use
setAlias", phar_obj->arc.archive->fname);
+ return;
+ }
+ phar_add_file(phar_obj->arc.archive, fname, fname_len, cont_str,
cont_len, zresource);
+}
+/* }}} */
+
/* {{{ proto int Phar::offsetUnset(string entry)
* remove a file from a phar
*/
@@ -2924,7 +2964,7 @@
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "Write operations disabled by INI setting");
return;
}
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname,
&fname_len) == FAILURE) {
return;
}
@@ -2951,6 +2991,71 @@
}
/* }}} */
+/* {{{ proto string Phar::addEmptyDir(string dirname)
+ * Adds an empty directory to the phar archive
+ */
+PHP_METHOD(Phar, addEmptyDir)
+{
+ char *dirname;
+ int dirname_len;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dirname,
&dirname_len) == FAILURE) {
+ return;
+ }
+
+ phar_mkdir(phar_obj->arc.archive, dirname, dirname_len);
+}
+/* }}} */
+
+/* {{{ proto string Phar::addFile(string filename[, string localname])
+ * Adds a file to the archive using the filename, or the second parameter as
the name within the archive
+ */
+PHP_METHOD(Phar, addFile)
+{
+ char *fname, *localname = NULL;
+ int fname_len, localname_len;
+ php_stream *resource;
+ zval *zresource;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &fname,
&fname_len, &localname, &localname_len) == FAILURE) {
+ return;
+ }
+
+ if (!(resource = php_stream_open_wrapper(fname, "rb", 0, NULL))) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
"phar error: unable to open file \"%s\" to add to phar archive", fname);
+ return;
+ }
+ if (localname) {
+ fname = localname;
+ fname_len = localname_len;
+ }
+
+ MAKE_STD_ZVAL(zresource);
+ php_stream_to_zval(resource, zresource);
+ phar_add_file(phar_obj->arc.archive, fname, fname_len, NULL, 0,
zresource);
+ efree(zresource);
+}
+/* }}} */
+
+/* {{{ proto string Phar::addFromString(string localname, string contents)
+ * Adds a file to the archive using its contents as a string
+ */
+PHP_METHOD(Phar, addFromString)
+{
+ char *localname, *cont_str;
+ int localname_len, cont_len;
+ PHAR_ARCHIVE_OBJECT();
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &localname,
&localname_len, &cont_str, &cont_len) == FAILURE) {
+ return;
+ }
+
+ phar_add_file(phar_obj->arc.archive, localname, localname_len,
cont_str, cont_len, NULL);
+}
+/* }}} */
+
/* {{{ proto string Phar::getStub()
* Returns the stub at the head of a phar archive as a string.
*/
@@ -3772,6 +3877,23 @@
ZEND_ARG_INFO(0, retphar)
ZEND_END_ARG_INFO();
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_emptydir, 0, 0, 0)
+ ZEND_ARG_INFO(0, dirname)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_addfile, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ ZEND_ARG_INFO(0, localname)
+ZEND_END_ARG_INFO();
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromstring, 0, 0, 1)
+ ZEND_ARG_INFO(0, localname)
+ ZEND_ARG_INFO(0, contents)
+ZEND_END_ARG_INFO();
+
#endif /* HAVE_SPL */
zend_function_entry php_archive_methods[] = {
@@ -3779,6 +3901,9 @@
PHP_ME(Phar, __construct, arginfo_phar___construct,
ZEND_ACC_PRIVATE)
#else
PHP_ME(Phar, __construct, arginfo_phar___construct,
ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir,
ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addFile, arginfo_phar_addfile,
ZEND_ACC_PUBLIC)
+ PHP_ME(Phar, addFromString, arginfo_phar_fromstring,
ZEND_ACC_PUBLIC)
PHP_ME(Phar, buildFromIterator, arginfo_phar_build,
ZEND_ACC_PUBLIC)
PHP_ME(Phar, compress, arginfo_phar_comp,
ZEND_ACC_PUBLIC)
PHP_ME(Phar, compressAllFilesBZIP2, NULL,
ZEND_ACC_PUBLIC)
http://cvs.php.net/viewvc.cgi/pecl/phar/util.c?r1=1.33&r2=1.34&diff_format=u
Index: pecl/phar/util.c
diff -u pecl/phar/util.c:1.33 pecl/phar/util.c:1.34
--- pecl/phar/util.c:1.33 Mon Mar 24 03:01:29 2008
+++ pecl/phar/util.c Wed Apr 9 19:23:30 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: util.c,v 1.33 2008/03/24 03:01:29 cellog Exp $ */
+/* $Id: util.c,v 1.34 2008/04/09 19:23:30 cellog Exp $ */
#include "phar_internal.h"
#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
@@ -436,7 +436,7 @@
return FAILURE;
}
if (allow_dir) {
- if ((entry = phar_get_entry_info_dir(phar, path, path_len, 2,
for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error TSRMLS_CC)) ==
NULL) {
+ if ((entry = phar_get_entry_info_dir(phar, path, path_len,
allow_dir, for_create && !PHAR_G(readonly) && !phar->is_data ? NULL : error
TSRMLS_CC)) == NULL) {
if (for_create && (!PHAR_G(readonly) || phar->is_data))
{
return SUCCESS;
}
@@ -564,11 +564,13 @@
}
etemp.fp_refcount = 1;
- if (is_dir) {
+ if (allow_dir == 2) {
etemp.is_dir = 1;
etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_DIR;
- etemp.filename_len--; /* strip trailing / */
- path_len--;
+ if (is_dir) {
+ etemp.filename_len--; /* strip trailing / */
+ path_len--;
+ }
} else {
etemp.flags = etemp.old_flags = PHAR_ENT_PERM_DEF_FILE;
}
@@ -1015,7 +1017,7 @@
}
return NULL;
}
- if (!entry->is_dir && is_dir) {
+ if (!entry->is_dir && dir == 2) {
/* user requested a directory, we must return one */
if (error) {
spprintf(error, 4096, "phar error: path \"%s\"
exists and is a not a directory", path);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/dir.phpt?r1=1.3&r2=1.4&diff_format=u
Index: pecl/phar/tests/dir.phpt
diff -u pecl/phar/tests/dir.phpt:1.3 pecl/phar/tests/dir.phpt:1.4
--- pecl/phar/tests/dir.phpt:1.3 Wed Jan 9 03:51:37 2008
+++ pecl/phar/tests/dir.phpt Wed Apr 9 19:23:30 2008
@@ -16,7 +16,7 @@
$phar = new Phar($fname);
var_dump($phar->isPhar());
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
var_dump($phar['test']->isDir());
var_dump($phar['test/']->isDir());
copy($fname, $fname2);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/tar/033.phpt?r1=1.3&r2=1.4&diff_format=u
Index: pecl/phar/tests/tar/033.phpt
diff -u pecl/phar/tests/tar/033.phpt:1.3 pecl/phar/tests/tar/033.phpt:1.4
--- pecl/phar/tests/tar/033.phpt:1.3 Tue Feb 12 16:39:58 2008
+++ pecl/phar/tests/tar/033.phpt Wed Apr 9 19:23:30 2008
@@ -14,7 +14,7 @@
$phar = new Phar($fname);
$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
$phar->setAlias('hio');
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
$phar->stopBuffering();
try {
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/tar/033a.phpt?r1=1.4&r2=1.5&diff_format=u
Index: pecl/phar/tests/tar/033a.phpt
diff -u pecl/phar/tests/tar/033a.phpt:1.4 pecl/phar/tests/tar/033a.phpt:1.5
--- pecl/phar/tests/tar/033a.phpt:1.4 Tue Feb 12 16:39:58 2008
+++ pecl/phar/tests/tar/033a.phpt Wed Apr 9 19:23:30 2008
@@ -14,7 +14,7 @@
$phar = new Phar($fname);
$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
$phar->setAlias('hio');
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
$phar->stopBuffering();
ini_set('phar.readonly', 1);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/tar/dir.phpt?r1=1.1&r2=1.2&diff_format=u
Index: pecl/phar/tests/tar/dir.phpt
diff -u pecl/phar/tests/tar/dir.phpt:1.1 pecl/phar/tests/tar/dir.phpt:1.2
--- pecl/phar/tests/tar/dir.phpt:1.1 Wed Jan 9 03:51:37 2008
+++ pecl/phar/tests/tar/dir.phpt Wed Apr 9 19:23:30 2008
@@ -16,7 +16,7 @@
$phar = new Phar($fname);
var_dump($phar->isTar());
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
var_dump($phar['test']->isDir());
var_dump($phar['test/']->isDir());
copy($fname, $fname2);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/zip/033.phpt?r1=1.4&r2=1.5&diff_format=u
Index: pecl/phar/tests/zip/033.phpt
diff -u pecl/phar/tests/zip/033.phpt:1.4 pecl/phar/tests/zip/033.phpt:1.5
--- pecl/phar/tests/zip/033.phpt:1.4 Mon Feb 11 20:55:42 2008
+++ pecl/phar/tests/zip/033.phpt Wed Apr 9 19:23:30 2008
@@ -14,7 +14,7 @@
$phar = new Phar($fname);
$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
$phar->setAlias('hio');
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
$phar->stopBuffering();
try {
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/zip/033a.phpt?r1=1.4&r2=1.5&diff_format=u
Index: pecl/phar/tests/zip/033a.phpt
diff -u pecl/phar/tests/zip/033a.phpt:1.4 pecl/phar/tests/zip/033a.phpt:1.5
--- pecl/phar/tests/zip/033a.phpt:1.4 Mon Feb 11 20:55:42 2008
+++ pecl/phar/tests/zip/033a.phpt Wed Apr 9 19:23:30 2008
@@ -14,7 +14,7 @@
$phar = new Phar($fname);
$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
$phar->setAlias('hio');
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
$phar->stopBuffering();
ini_set('phar.readonly', 1);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/zip/dir.phpt?r1=1.3&r2=1.4&diff_format=u
Index: pecl/phar/tests/zip/dir.phpt
diff -u pecl/phar/tests/zip/dir.phpt:1.3 pecl/phar/tests/zip/dir.phpt:1.4
--- pecl/phar/tests/zip/dir.phpt:1.3 Mon Jan 28 16:49:27 2008
+++ pecl/phar/tests/zip/dir.phpt Wed Apr 9 19:23:30 2008
@@ -16,7 +16,7 @@
$phar = new Phar($fname);
var_dump($phar->isZip());
-$phar['test/'] = '';
+$phar->addEmptyDir('test');
var_dump($phar['test']->isDir());
var_dump($phar['test/']->isDir());
copy($fname, $fname2);
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/addfuncs.phpt?view=markup&rev=1.1
Index: pecl/phar/tests/addfuncs.phpt
+++ pecl/phar/tests/addfuncs.phpt
--TEST--
Phar: addFile/addFromString
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
phar.readonly=0
--FILE--
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->addFromString('a', 'hi');
echo file_get_contents($pname . '/a') . "\n";
$phar->addFile($pname . '/a', 'b');
echo file_get_contents($pname . '/b') . "\n";
try {
$phar->addFile($pname . '/a');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$phar->addFile($pname . '/a', 'a');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') .
'.phar.php'); ?>
--EXPECTF--
hi
hi
Entry phar://%saddfuncs.phar.php/a does not exist and cannot be created: phar
error: invalid path "phar://%saddfuncs.phar.php/a" contains double slash
Entry a does not exist and cannot be created: phar error: file "a" in phar
"%saddfuncs.phar.php" cannot be opened for writing, readable file pointers are
open
===DONE===