helly Thu Mar 31 16:51:46 2005 EDT
Modified files:
/php-src/ext/spl spl_directory.c spl_directory.h
Log:
- Add RecursiveDirectoryIterator::getSubPath()
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.39&r2=1.40&ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.39
php-src/ext/spl/spl_directory.c:1.40
--- php-src/ext/spl/spl_directory.c:1.39 Wed Mar 9 05:29:27 2005
+++ php-src/ext/spl/spl_directory.c Thu Mar 31 16:51:45 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.39 2005/03/09 10:29:27 helly Exp $ */
+/* $Id: spl_directory.c,v 1.40 2005/03/31 21:51:45 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -73,6 +73,9 @@
if (intern->path_name) {
efree(intern->path_name);
}
+ if (intern->sub_path) {
+ efree(intern->sub_path);
+ }
efree(object);
}
/* }}} */
@@ -540,6 +543,7 @@
{
zval *object = getThis(), zpath;
spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
+ spl_ce_dir_object *subdir;
spl_dir_get_path_name(intern);
@@ -547,6 +551,31 @@
ZVAL_STRINGL(&zpath, intern->path_name, intern->path_name_len, 0);
spl_instantiate_arg_ex1(spl_ce_RecursiveDirectoryIterator,
&return_value, 0, &zpath TSRMLS_CC);
+
+ subdir = (spl_ce_dir_object*)zend_object_store_get_object(return_value
TSRMLS_CC);
+ if (subdir) {
+ if (intern->sub_path && intern->sub_path[0]) {
+ subdir->sub_path_len = spprintf(&subdir->sub_path, 0,
"%s/%s", intern->sub_path, intern->entry.d_name);
+ } else {
+ subdir->sub_path_len = strlen(intern->entry.d_name);
+ subdir->sub_path = estrndup(intern->entry.d_name,
subdir->sub_path_len);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ proto void RecursiveDirectoryIterator::rewind()
+ Get sub path */
+SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
+{
+ zval *object = getThis();
+ spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
+
+ if (intern->sub_path) {
+ RETURN_STRINGL(intern->sub_path, intern->sub_path_len, 1);
+ } else {
+ RETURN_STRINGL("", 0, 1);
+ }
}
/* }}} */
@@ -818,6 +847,7 @@
SPL_ME(RecursiveDirectoryIterator, key, NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
SPL_ME(RecursiveDirectoryIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveDirectoryIterator, getSubPath, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.h?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.8 php-src/ext/spl/spl_directory.h:1.9
--- php-src/ext/spl/spl_directory.h:1.8 Sun Mar 6 19:40:57 2005
+++ php-src/ext/spl/spl_directory.h Thu Mar 31 16:51:46 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.h,v 1.8 2005/03/07 00:40:57 helly Exp $ */
+/* $Id: spl_directory.h,v 1.9 2005/03/31 21:51:46 helly Exp $ */
#ifndef SPL_DIRECTORY_H
#define SPL_DIRECTORY_H
@@ -37,6 +37,8 @@
char *path;
char *path_name;
int path_name_len;
+ char *sub_path;
+ int sub_path_len;
int index;
} spl_ce_dir_object;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php