static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
{
php_url *resource_from, *resource_to;
- char *from_file, *to_file;
- char *error;
+ char *from_file, *to_file, *error, *plain_map;
phar_entry_data *fromdata, *todata;
+ uint host_len;
if (PHAR_G(readonly)) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by INI setting");
return 0;
}
- /*TODO: handle extract_list */
if (strcmp(resource_from->host, resource_to->host)) {
php_url_free(resource_from);
php_url_free(resource_to);
return 0;
}
+ host_len = strlen(resource_from->host);
+ if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource_from->host, host_len+1, (void **)&plain_map) == SUCCESS) {
+ /*TODO:use php_stream_rename() once available*/
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive", url_from, url_to);
+ return 0;
+ }
+
/* need to copy to strip leading "/", will get touched again */
from_file = estrdup(resource_from->path + 1);
to_file = estrdup(resource_to->path + 1);