]> granicus.if.org Git - php/commitdiff
@- Added optional 3rd parameter 'recursive' to ftp_rawlist() which will
authorfoobar <sniper@php.net>
Thu, 4 Jul 2002 13:48:48 +0000 (13:48 +0000)
committerfoobar <sniper@php.net>
Thu, 4 Jul 2002 13:48:48 +0000 (13:48 +0000)
@  do 'LIST -R' instead of 'LIST'. (Jani)
# tested too..and it even works. :)
# (removed that Z_TYPE_P() pollution also..)

ext/ftp/ftp.c
ext/ftp/ftp.h
ext/ftp/php_ftp.c

index d7d7d8a8f1f9e16a409dc9f62740caebf6be1562..575cb40f45e62f475af54e0a06884769273ad76b 100644 (file)
@@ -412,9 +412,9 @@ ftp_nlist(ftpbuf_t *ftp, const char *path)
 /* {{{ ftp_list
  */
 char**
-ftp_list(ftpbuf_t *ftp, const char *path)
+ftp_list(ftpbuf_t *ftp, const char *path, int recursive)
 {
-       return ftp_genlist(ftp, "LIST", path);
+       return ftp_genlist(ftp, ((recursive) ? "LIST -R" : "LIST"), path);
 }
 /* }}} */
 
@@ -428,7 +428,7 @@ ftp_type(ftpbuf_t *ftp, ftptype_t type)
        if (ftp == NULL)
                return 0;
 
-       if (type == Z_TYPE_P(ftp))
+       if (type == ftp->type)
                return 1;
 
        if (type == FTPTYPE_ASCII)
@@ -443,7 +443,7 @@ ftp_type(ftpbuf_t *ftp, ftptype_t type)
        if (!ftp_getresp(ftp) || ftp->resp != 200)
                return 0;
 
-       Z_TYPE_P(ftp) = type;
+       ftp->type = type;
 
        return 1;
 }
@@ -1042,7 +1042,7 @@ ftp_getdata(ftpbuf_t *ftp)
        }
        data->listener = -1;
        data->fd = -1;
-       Z_TYPE_P(data) = Z_TYPE_P(ftp);
+       data->type = ftp->type;
 
        sa = (struct sockaddr *) &ftp->localaddr;
        /* bind/listen */
index b201045f9bd605ffabc76f415e4f6c746bbb28f6..f980a8c757d65c05a739c555d2d6fb3ee68d779f 100644 (file)
@@ -120,7 +120,7 @@ char**              ftp_nlist(ftpbuf_t *ftp, const char *path);
  * array must be freed (but don't
  * free the array elements)
  */
-char**         ftp_list(ftpbuf_t *ftp, const char *path);
+char**         ftp_list(ftpbuf_t *ftp, const char *path, int recursive);
 
 /* switches passive mode on or off
  * returns true on success, false on error
index 2b91ed94cd7c32e33f7cb8798b2b07c0dfe6f625..7a8b665b188954c1afa19594f6f41b66ff177bbb 100644 (file)
@@ -342,7 +342,7 @@ PHP_FUNCTION(ftp_nlist)
 }
 /* }}} */
 
-/* {{{ proto array ftp_rawlist(resource stream, string directory)
+/* {{{ proto array ftp_rawlist(resource stream, string directory [, bool recursive])
    Returns a detailed listing of a directory as an array of output lines */
 PHP_FUNCTION(ftp_rawlist)
 {
@@ -350,15 +350,16 @@ PHP_FUNCTION(ftp_rawlist)
        ftpbuf_t        *ftp;
        char            **llist, **ptr, *dir;
        int                     dir_len;
+       zend_bool       recursive;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &dir, &dir_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|b", &z_ftp, &dir, &dir_len, &recursive) == FAILURE) {
                return;
        }
 
        ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
 
        /* get raw directory listing */
-       if (NULL == (llist = ftp_list(ftp, dir))) {
+       if (NULL == (llist = ftp_list(ftp, dir, recursive))) {
                RETURN_FALSE;
        }