cvs: php-src(PHP_5_1) /ext/spl spl_directory.c spl_directory.h
| From: | Marcus Boerger | Date: | Tue, 28 Feb 2006 01:33:32 +0000 |
| Subject: | cvs: php-src(PHP_5_1) /ext/spl spl_directory.c spl_directory.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-37052@lists.php.net to get a copy of this message | ||
helly Tue Feb 28 01:33:32 2006 UTC
Modified files: (Branch: PHP_5_1)
/php-src/ext/spl spl_directory.c spl_directory.h
Log:
- MFH Fix issues withhandling of derived info classes as entries
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.20&r2=1.45.2.21&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.20 php-src/ext/spl/spl_directory.c:1.45.2.21
--- php-src/ext/spl/spl_directory.c:1.45.2.20 Fri Feb 10 16:57:56 2006
+++ php-src/ext/spl/spl_directory.c Tue Feb 28 01:33:32 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.45.2.20 2006/02/10 16:57:56 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.21 2006/02/28 01:33:32 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -268,6 +268,8 @@
intern->file_class = source->file_class;
intern->info_class = source->info_class;
+ intern->flags = source->flags;
+ intern->oth = source->oth;
zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC);
@@ -299,6 +301,7 @@
static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_object *source,
char *file_path, int file_path_len, int use_copy, zend_class_entry *ce, zval *return_value
TSRMLS_DC) /* {{{ */
{
spl_filesystem_object *intern;
+ zval *arg1;
if (!file_path || !file_path_len) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot create SplFileInfo for
empty path");
@@ -311,10 +314,18 @@
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
- return_value->value.obj = spl_filesystem_object_new_ex(ce ? ce : source->info_class,
&intern TSRMLS_CC);
+ ce = ce ? ce : source->info_class;
+ return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;
- spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy TSRMLS_CC);
+ if (ce->constructor->common.scope != spl_ce_SplFileInfo) {
+ MAKE_STD_ZVAL(arg1);
+ ZVAL_STRINGL(arg1, file_path, file_path_len, use_copy);
+ zend_call_method_with_1_params(&return_value, ce, &ce->constructor,
"__construct", NULL, arg1);
+ zval_ptr_dtor(&arg1);
+ } else {
+ spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy TSRMLS_CC);
+ }
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
@@ -325,6 +336,7 @@
{
spl_filesystem_object *intern;
zend_bool use_include_path = 0;
+ zval *arg1, *arg2;
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
@@ -342,41 +354,61 @@
switch (type) {
case SPL_FS_INFO:
- return_value->value.obj = spl_filesystem_object_new_ex(ce ? ce : source->info_class,
&intern TSRMLS_CC);
+ ce = ce ? ce : source->info_class;
+ return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;
-
+
spl_filesystem_object_get_file_name(source TSRMLS_CC);
- intern->file_name = estrndup(source->file_name, source->file_name_len);
- intern->file_name_len = source->file_name_len;
- intern->path = estrndup(source->path, source->path_len);
- intern->path_len = source->path_len;
+ if (ce->constructor->common.scope != spl_ce_SplFileInfo) {
+ MAKE_STD_ZVAL(arg1);
+ ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1);
+ zend_call_method_with_1_params(&return_value, ce, &ce->constructor,
"__construct", NULL, arg1);
+ zval_ptr_dtor(&arg1);
+ } else {
+ intern->file_name = estrndup(source->file_name, source->file_name_len);
+ intern->file_name_len = source->file_name_len;
+ intern->path = estrndup(source->path, source->path_len);
+ intern->path_len = source->path_len;
+ }
break;
case SPL_FS_FILE:
- return_value->value.obj = spl_filesystem_object_new_ex(ce ? ce : source->file_class,
&intern TSRMLS_CC);
+ ce = ce ? ce : source->file_class;
+ return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
Z_TYPE_P(return_value) = IS_OBJECT;
spl_filesystem_object_get_file_name(source TSRMLS_CC);
- intern->file_name = source->file_name;
- intern->file_name_len = source->file_name_len;
-
- intern->u.file.open_mode = "r";
- intern->u.file.open_mode_len = 1;
-
- if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sbr",
- &intern->u.file.open_mode, &intern->u.file.open_mode_len,
- &use_include_path, &intern->u.file.zcontext) == FAILURE) {
- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- intern->u.file.open_mode = NULL;
- zval_dtor(return_value);
- Z_TYPE_P(return_value) = IS_NULL;
- return NULL;
- }
-
- if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == FAILURE) {
- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- zval_dtor(return_value);
- Z_TYPE_P(return_value) = IS_NULL;
- return NULL;
+
+ if (ce->constructor->common.scope != spl_ce_SplFileObject) {
+ MAKE_STD_ZVAL(arg1);
+ MAKE_STD_ZVAL(arg2);
+ ZVAL_STRINGL(arg1, source->file_name, source->file_name_len, 1);
+ ZVAL_STRINGL(arg2, "r", 1, 1);
+ zend_call_method_with_2_params(&return_value, ce, &ce->constructor,
"__construct", NULL, arg1, arg2);
+ zval_ptr_dtor(&arg1);
+ zval_ptr_dtor(&arg2);
+ } else {
+ intern->file_name = source->file_name;
+ intern->file_name_len = source->file_name_len;
+
+ intern->u.file.open_mode = "r";
+ intern->u.file.open_mode_len = 1;
+
+ if (ht && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sbr",
+ &intern->u.file.open_mode, &intern->u.file.open_mode_len,
+ &use_include_path, &intern->u.file.zcontext) == FAILURE) {
+ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ intern->u.file.open_mode = NULL;
+ zval_dtor(return_value);
+ Z_TYPE_P(return_value) = IS_NULL;
+ return NULL;
+ }
+
+ if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == FAILURE) {
+ php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+ zval_dtor(return_value);
+ Z_TYPE_P(return_value) = IS_NULL;
+ return NULL;
+ }
}
break;
case SPL_FS_DIR:
@@ -735,7 +767,7 @@
return;
}
- intern->file_class = ce;
+ intern->info_class = ce;
}
/* }}} */
@@ -879,7 +911,10 @@
subdir->u.dir.sub_path_len = strlen(intern->u.dir.entry.d_name);
subdir->u.dir.sub_path = estrndup(intern->u.dir.entry.d_name,
subdir->u.dir.sub_path_len);
}
+ subdir->info_class = intern->info_class;
+ subdir->file_class = intern->file_class;
subdir->flags = intern->flags;
+ subdir->oth = intern->oth;
}
}
/* }}} */
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_directory.h?r1=1.12.2.3&r2=1.12.2.4&diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.12.2.3 php-src/ext/spl/spl_directory.h:1.12.2.4
--- php-src/ext/spl/spl_directory.h:1.12.2.3 Sun Jan 1 12:50:13 2006
+++ php-src/ext/spl/spl_directory.h Tue Feb 28 01:33:32 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.h,v 1.12.2.3 2006/01/01 12:50:13 sniper Exp $ */
+/* $Id: spl_directory.h,v 1.12.2.4 2006/02/28 01:33:32 helly Exp $ */
#ifndef SPL_DIRECTORY_H
#define SPL_DIRECTORY_H
@@ -40,6 +40,7 @@
typedef struct _spl_filesystem_object {
zend_object std;
+ void *oth;
char *path;
int path_len;
char *file_name;