From: Marcus Boerger Date: Thu, 31 Mar 2005 23:02:20 +0000 (+0000) Subject: - Add RecursiveDirectoryIterator::getSubPathname() X-Git-Tag: php-5.0.1b1~644 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7adb2b0c0b4cd98b6e1b0c29043867ae6c458ac2;p=php - Add RecursiveDirectoryIterator::getSubPathname() --- diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index a8eb63595e..93f5a4c68c 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -564,7 +564,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren) } /* }}} */ -/* {{{ proto void RecursiveDirectoryIterator::rewind() +/* {{{ proto void RecursiveDirectoryIterator::getSubPath() Get sub path */ SPL_METHOD(RecursiveDirectoryIterator, getSubPath) { @@ -579,6 +579,24 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPath) } /* }}} */ +/* {{{ proto void RecursiveDirectoryIterator::getSubPathname() + Get sub path and file name */ +SPL_METHOD(RecursiveDirectoryIterator, getSubPathname) +{ + zval *object = getThis(); + spl_ce_dir_object *intern = (spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC); + char *sub_name; + int len; + + if (intern->sub_path) { + len = spprintf(&sub_name, 0, "%s/%s", intern->sub_path, intern->entry.d_name); + RETURN_STRINGL(sub_name, len, 0); + } else { + RETURN_STRING(intern->entry.d_name, 1); + } +} +/* }}} */ + /* define an overloaded iterator structure */ typedef struct { zend_object_iterator intern; @@ -848,6 +866,7 @@ static zend_function_entry spl_ce_dir_tree_class_functions[] = { SPL_ME(RecursiveDirectoryIterator, hasChildren, NULL, ZEND_ACC_PUBLIC) SPL_ME(RecursiveDirectoryIterator, getChildren, NULL, ZEND_ACC_PUBLIC) SPL_ME(RecursiveDirectoryIterator, getSubPath, NULL, ZEND_ACC_PUBLIC) + SPL_ME(RecursiveDirectoryIterator, getSubPathname,NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} };