]> granicus.if.org Git - php/commitdiff
- Support virtual unlink()
authorAndi Gutmans <andi@php.net>
Tue, 23 May 2000 14:36:27 +0000 (14:36 +0000)
committerAndi Gutmans <andi@php.net>
Tue, 23 May 2000 14:36:27 +0000 (14:36 +0000)
ext/db/db.c
ext/session/mod_files.c
ext/standard/file.c
ext/standard/link.c
main/php.h
main/php_virtual_cwd.c
main/php_virtual_cwd.h

index 07cdefc5ba2fb5a7bf5c2c2433e6f6d208d70fdd..ed64c9c14ae633ce0854c5f0d6a15f3a34f3289e 100644 (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));
index c3fc91bb3f486ec3190827a4801a2e189de8898b..aefebc1df5a5efa8d45a0ad44ffc8f246c94a898 100644 (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;
 }
index 9c42e108f9647f98948ecdae737d99015c6c8faa..57569e73b0d3e2e0f2b63c62f20b0e8fc23ffedd 100644 (file)
@@ -231,7 +231,7 @@ static void _file_socket_dtor(int *sock)
 
 static void _file_upload_dtor(char *file)
 {
-       unlink(file);
+       V_UNLINK(file);
 }
 
 
index ffe14235efa5033a416691e3aa59d2a818d9f15b..2fb126afa3cb3d75f30fcedea83a955833de6192 100644 (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;
index cdbbaabeb20a9579674ccd55794c8109b4dd61b2..9cc2f8b0404b89412b32902e3832f5afcd8cf4c1 100644 (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"
index 3a1097963cf5546fa521d2c1342fff5f4a6d00ad..765d3215d99372db73815bc5b08bef83f535b210 100644 (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)
index 5622c2d0fd70480852d4d72665e3fbb8892376b0..c893c8d02006166b3f5d4295bb5bc53b2e30364b 100644 (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)