diff options
author | Andrew Skalski <askalski@php.net> | 1999-10-04 18:30:37 +0000 |
---|---|---|
committer | Andrew Skalski <askalski@php.net> | 1999-10-04 18:30:37 +0000 |
commit | f1f8b8a9a2d907c8c4a9020b4fa766ed467cb096 (patch) | |
tree | 623878ff3402c8ace23f637fd7d37176ff0b883f /ext/ftp/php_ftp.c | |
parent | 7aed3d51fc6377b82fa0b01c2ed14ab37c83b8b9 (diff) | |
download | php-git-f1f8b8a9a2d907c8c4a9020b4fa766ed467cb096.tar.gz |
Added delete and rename functions.
Diffstat (limited to 'ext/ftp/php_ftp.c')
-rw-r--r-- | ext/ftp/php_ftp.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 2307b0aa9c..07f8ff59a6 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -64,6 +64,8 @@ function_entry php3_ftp_functions[] = { PHP_FE(ftp_fput, NULL) PHP_FE(ftp_size, NULL) PHP_FE(ftp_mdtm, NULL) + PHP_FE(ftp_rename, NULL) + PHP_FE(ftp_delete, NULL) PHP_FE(ftp_quit, NULL) {NULL, NULL, NULL} }; @@ -714,6 +716,66 @@ PHP_FUNCTION(ftp_mdtm) } /* }}} */ +/* {{{ proto int ftp_rename(int stream, string src, string dest) + Renames the given file to a new path */ +PHP_FUNCTION(ftp_rename) +{ + pval *arg1, *arg2, *arg3; + ftpbuf_t *ftp; + + /* arg1 - ftp + * arg2 - src + * arg3 - dest + */ + if ( ARG_COUNT(ht) != 3 || + getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + FTPBUF(ftp, arg1); + convert_to_string(arg2); + convert_to_string(arg3); + + /* rename the file */ + if (!ftp_rename(ftp, arg2->value.str.val, arg3->value.str.val)) { + php_error(E_WARNING, "ftp_rename: %s", ftp->inbuf); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int ftp_delete(int stream, string path) + Deletes a file */ +PHP_FUNCTION(ftp_delete) +{ + pval *arg1, *arg2; + ftpbuf_t *ftp; + + /* arg1 - ftp + * arg2 - path + */ + if ( ARG_COUNT(ht) != 2 || + getParameters(ht, 2, &arg1, &arg2) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + FTPBUF(ftp, arg1); + convert_to_string(arg2); + + /* delete the file */ + if (!ftp_delete(ftp, arg2->value.str.val)) { + php_error(E_WARNING, "ftp_delete: %s", ftp->inbuf); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto int ftp_quit(int stream) Closes the FTP stream */ PHP_FUNCTION(ftp_quit) |