/* {{{ 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);
}
/* }}} */
if (ftp == NULL)
return 0;
- if (type == Z_TYPE_P(ftp))
+ if (type == ftp->type)
return 1;
if (type == FTPTYPE_ASCII)
if (!ftp_getresp(ftp) || ftp->resp != 200)
return 0;
- Z_TYPE_P(ftp) = type;
+ ftp->type = type;
return 1;
}
}
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 */
* 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
}
/* }}} */
-/* {{{ 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)
{
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;
}