return NULL;
} /* }}} */
+static inline int spl_filesystem_is_dot(const char * d_name) /* {{{ */
+{
+ return !strcmp(d_name, ".") || !strcmp(d_name, "..");
+}
+/* }}} */
+
+static int spl_filesystem_is_invalid_or_dot(const char * d_name) /* {{{ */
+{
+ return d_name[0] == '\0' || spl_filesystem_is_dot(d_name);
+}
+/* }}} */
+
static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{{ */
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(obj TSRMLS_CC);
}
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
- } while (!strcmp(intern->u.dir.entry.d_name, ".") || !strcmp(intern->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
}
/* }}} */
intern->u.dir.index++;
do {
spl_filesystem_dir_read(intern TSRMLS_CC);
- } while (!strcmp(intern->u.dir.entry.d_name, ".") || !strcmp(intern->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
if (intern->file_name.v) {
efree(intern->file_name.v);
intern->file_name = NULL_ZSTR;
zend_bool allow_links = 0;
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- if (!strcmp(intern->u.dir.entry.d_name, ".") || !strcmp(intern->u.dir.entry.d_name, "..")) {
+ if (spl_filesystem_is_invalid_or_dot(intern->u.dir.entry.d_name)) {
RETURN_FALSE;
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &allow_links) == FAILURE) {
object->u.dir.index++;
do {
spl_filesystem_dir_read(object TSRMLS_CC);
- } while (!strcmp(object->u.dir.entry.d_name, ".") || !strcmp(object->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(object->u.dir.entry.d_name));
if (object->file_name.v) {
efree(object->file_name.v);
object->file_name = NULL_ZSTR;
}
do {
spl_filesystem_dir_read(object TSRMLS_CC);
- } while (!strcmp(object->u.dir.entry.d_name, ".") || !strcmp(object->u.dir.entry.d_name, ".."));
+ } while (spl_filesystem_is_dot(object->u.dir.entry.d_name));
if (iterator->current) {
zval_ptr_dtor(&iterator->current);
iterator->current = NULL;
spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_ParentIterator, spl_ce_RecursiveIterator, DIT_ParentIterator);
} /* }}} */
-/* {{{ proto bool ParentIterator::hasChildren() U
- Check whether the inner iterator's current element has children */
-SPL_METHOD(ParentIterator, hasChildren)
-{
- spl_dual_it_object *intern;
- zval *retval;
-
- intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
- if (retval) {
- RETURN_ZVAL(retval, 0, 1);
- } else {
- RETURN_FALSE;
- }
-} /* }}} */
-
-/* {{{ proto ParentIterator ParentIterator::getChildren() U
- Return the inner iterator's children contained in a ParentIterator */
-SPL_METHOD(ParentIterator, getChildren)
-{
- spl_dual_it_object *intern;
- zval *retval;
-
- intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
- if (!EG(exception) && retval) {
- spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, retval TSRMLS_CC);
- }
- if (retval) {
- zval_ptr_dtor(&retval);
- }
-} /* }}} */
-
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int mode [, int flags [, int preg_flags]]]) U
Create an RegexIterator from another iterator and a regular expression */
static zend_function_entry spl_funcs_ParentIterator[] = {
SPL_ME(ParentIterator, __construct, arginfo_parent_it___construct, ZEND_ACC_PUBLIC)
- SPL_MA(ParentIterator, accept, ParentIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(ParentIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(ParentIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(dual_it, getInnerIterator, NULL, ZEND_ACC_PUBLIC)
+ SPL_MA(ParentIterator, accept, RecursiveFilterIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
ZEND_END_ARG_INFO();
static zend_function_entry spl_funcs_RecursiveRegexIterator[] = {
- SPL_ME(RecursiveRegexIterator, __construct, arginfo_rec_regex_it___construct, ZEND_ACC_PUBLIC)
- SPL_ME(ParentIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
- SPL_ME(RecursiveRegexIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveRegexIterator, __construct, arginfo_rec_regex_it___construct, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveFilterIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(RecursiveRegexIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
#endif