- Support virtual unlink()

This commit is contained in:
Andi Gutmans 2000-05-23 14:36:27 +00:00
parent 0eb51100b7
commit 521f03c184
7 changed files with 25 additions and 6 deletions

View File

@ -399,7 +399,7 @@ dbm_info *php_dbm_open(char *filename, char *mode) {
#if NFS_HACK
if (lockfn) {
unlink(lockfn);
V_UNLINK(lockfn);
}
#endif
if (lockfn) efree(lockfn);
@ -434,7 +434,7 @@ int php_dbm_close(dbm_info *info) {
dbf = info->dbf;
#if NFS_HACK
unlink(info->lockfn);
V_UNLINK(info->lockfn);
#else
if (info->lockfn) {
lockfd = V_OPEN((info->lockfn,O_RDWR,0644));

View File

@ -178,7 +178,7 @@ static int _ps_files_cleanup_dir(const char *dirname, int maxlifetime)
V_STAT(buf, &sbuf) == 0 &&
/* is it expired? */
(now - sbuf.st_atime) > maxlifetime) {
unlink(buf);
V_UNLINK(buf);
nrdels++;
}
}
@ -276,7 +276,7 @@ PS_DESTROY_FUNC(files)
if (!_ps_files_path_create(buf, sizeof(buf), data, key))
return FAILURE;
unlink(buf);
V_UNLINK(buf);
return SUCCESS;
}

View File

@ -231,7 +231,7 @@ static void _file_socket_dtor(int *sock)
static void _file_upload_dtor(char *file)
{
unlink(file);
V_UNLINK(file);
}

View File

@ -181,7 +181,7 @@ PHP_FUNCTION(unlink)
RETURN_FALSE;
}
ret = unlink((*filename)->value.str.val);
ret = V_UNLINK((*filename)->value.str.val);
if (ret == -1) {
php_error(E_WARNING, "Unlink failed (%s)", strerror(errno));
RETURN_FALSE;

View File

@ -308,6 +308,7 @@ PHPAPI int cfg_get_string(char *varname, char **result);
#else
#define V_LSTAT(path, buff) virtual_lstat(path, buff)
#endif
#define V_UNLINK(path) virtual_unlink(path)
#else
#define V_GETCWD(buff, size) getcwd(buff,size)
#define V_FOPEN(path, mode) fopen(path, mode)
@ -318,6 +319,7 @@ PHPAPI int cfg_get_string(char *varname, char **result);
#define V_GETWD(buf) getwd(buf)
#define V_STAT(path, buff) stat(path, buff)
#define V_LSTAT(path, buff) lstat(path, buff)
#define V_UNLINK(path) unlink(path)
#endif
#include "zend_constants.h"

View File

@ -471,6 +471,21 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf)
#endif
CWD_API int virtual_unlink(const char *path)
{
cwd_state new_state;
int retval;
CWDLS_FETCH();
CWD_STATE_COPY(&new_state, &CWDG(cwd));
virtual_file_ex(&new_state, path, NULL);
retval = unlink(new_state.cwd);
CWD_STATE_FREE(&new_state);
return retval;
}
#if 0
main(void)

View File

@ -48,6 +48,8 @@ CWD_API int virtual_stat(const char *path, struct stat *buf);
#ifndef ZEND_WIN32
CWD_API int virtual_lstat(const char *path, struct stat *buf);
#endif
CWD_API int virtual_unlink(const char *path);
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
ZEND_BEGIN_MODULE_GLOBALS(cwd)