cellog Wed Apr 9 19:23:30 2008 UTC
Added files:
/pecl/phar/testsaddfuncs.phpt
Modified files:
/pecl/phar dirstream.c phar_object.c util.c
/pecl/phar/testsdir.phpt
/pecl/phar/tests/tar033.phpt 033a.phpt dir.phpt
/pecl/phar/tests/zip033.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.13r2=1.14diff_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.195r2=1.196diff_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 ||