diff options
author | Andi Gutmans <andi@php.net> | 2000-07-02 15:12:34 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2000-07-02 15:12:34 +0000 |
commit | b9037f7d691bf1a88d6aaf708d3babb28836c468 (patch) | |
tree | 7c75c6d3f5c9c53b4dfc59f2c63c00e48c66fb40 /ext/standard/file.c | |
parent | 0249137148921d463d9c79c89592db914dfbb642 (diff) | |
download | php-git-b9037f7d691bf1a88d6aaf708d3babb28836c468.tar.gz |
- Make PHP compile again under Windows.
- Please be careful when you make such changes.
Diffstat (limited to 'ext/standard/file.c')
-rw-r--r-- | ext/standard/file.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index 99ae196904..e03e9db77d 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -27,6 +27,7 @@ #include "php_globals.h" #include "ext/standard/flock_compat.h" #include "ext/standard/exec.h" +#include "ext/standard/php_filestat.h" #include <stdio.h> #include <stdlib.h> @@ -1575,11 +1576,10 @@ PHP_FUNCTION(fpassthru) zend_list_delete((*arg1)->value.lval); RETURN_LONG(size); } - /* }}} */ + /* {{{ proto int rename(string old_name, string new_name) Rename a file */ - PHP_FUNCTION(rename) { pval **old_arg, **new_arg; @@ -1609,8 +1609,38 @@ PHP_FUNCTION(rename) RETVAL_TRUE; } +/* }}} */ + +/* {{{ proto int unlink(string filename) + Delete a file */ +PHP_FUNCTION(unlink) +{ + pval **filename; + int ret; + PLS_FETCH(); + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(filename); + + if (PG(safe_mode) && !php_checkuid((*filename)->value.str.val, NULL, 2)) { + RETURN_FALSE; + } + + ret = V_UNLINK((*filename)->value.str.val); + if (ret == -1) { + php_error(E_WARNING, "Unlink failed (%s)", strerror(errno)); + RETURN_FALSE; + } + /* Clear stat cache */ + PHP_FN(clearstatcache)(INTERNAL_FUNCTION_PARAM_PASSTHRU); + RETURN_TRUE; +} /* }}} */ + + /* {{{ proto int ftruncate (int fp, int size) Truncate file to 'size' length */ PHP_FUNCTION(ftruncate) |