mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
- Support virtual unlink()
This commit is contained in:
parent
0eb51100b7
commit
521f03c184
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ static void _file_socket_dtor(int *sock)
|
||||
|
||||
static void _file_upload_dtor(char *file)
|
||||
{
|
||||
unlink(file);
|
||||
V_UNLINK(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;
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user