]> granicus.if.org Git - php/commitdiff
- Add RecursiveDirectoryIterator::getSubPathname()
authorMarcus Boerger <helly@php.net>
Thu, 31 Mar 2005 23:02:20 +0000 (23:02 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 31 Mar 2005 23:02:20 +0000 (23:02 +0000)
ext/spl/spl_directory.c

index a8eb63595ee9f9fdbd168fc5d5ee592ca38060a5..93f5a4c68c1364e3470bbf8fed76c3cc794a816b 100755 (executable)
@@ -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}
 };