]> granicus.if.org Git - php/commitdiff
- Add V_RENAME() by "Daniel Beulshausen" <daniel@php4win.de>.
authorAndi Gutmans <andi@php.net>
Thu, 26 Oct 2000 05:21:52 +0000 (05:21 +0000)
committerAndi Gutmans <andi@php.net>
Thu, 26 Oct 2000 05:21:52 +0000 (05:21 +0000)
- It is untested and all places which use rename() in PHP should now use
- V_RENAME().

TSRM/tsrm_virtual_cwd.c
TSRM/tsrm_virtual_cwd.h

index 64d58f49bf89c4c438f505f49132cb94f1c4f2c2..a394e121280dfd06e466ad08f94d116db6dc8db7 100644 (file)
@@ -574,6 +574,28 @@ CWD_API int virtual_creat(const char *path, mode_t mode)
        return f;
 }
 
+CWD_API int virtual_rename(char *oldname, char *newname)
+{
+       cwd_state old_state;
+       cwd_state new_state;
+       int retval;
+       CWDLS_FETCH();
+
+       CWD_STATE_COPY(&old_state, &CWDG(cwd));
+       virtual_file_ex(&old_state, oldname, NULL);
+       oldname = old_state.cwd;
+
+       CWD_STATE_COPY(&new_state, &CWDG(cwd));
+       virtual_file_ex(&new_state, newname, NULL);
+       newname = new_state.cwd;
+       retval = rename(oldname, newname);
+
+       CWD_STATE_FREE(&old_state);
+       CWD_STATE_FREE(&new_state);
+
+       return retval;
+}
 
 CWD_API int virtual_stat(const char *path, struct stat *buf)
 {
index 1ba78a6e4a5926969e31237c55a6238089b7432f..db0afdd897a81e942b73d811676476dcd0ff5b91 100644 (file)
@@ -104,6 +104,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path);
 CWD_API FILE *virtual_fopen(const char *path, const char *mode);
 CWD_API int virtual_open(const char *path, int flags, ...);
 CWD_API int virtual_creat(const char *path, mode_t mode);
+CWD_API int virtual_rename(char *oldname, char *newname);
 CWD_API int virtual_stat(const char *path, struct stat *buf);
 #ifndef TSRM_WIN32
 CWD_API int virtual_lstat(const char *path, struct stat *buf);
@@ -159,6 +160,7 @@ typedef struct _virtual_cwd_globals {
 #define V_CHDIR_FILE(path) virtual_chdir_file(path, virtual_chdir)
 #define V_GETWD(buf)
 #define V_REALPATH(path,real_path) virtual_realpath(path,real_path)
+#define V_RENAME(oldname,newname) virtual_rename(oldname,newname)
 #define V_STAT(path, buff) virtual_stat(path, buff)
 #ifdef TSRM_WIN32
 #define V_LSTAT(path, buff) virtual_stat(path, buff)
@@ -184,6 +186,7 @@ typedef struct _virtual_cwd_globals {
 #define V_FOPEN(path, mode)  fopen(path, mode)
 #define V_OPEN(open_args) open open_args
 #define V_CREAT(path, mode) creat(path, mode)
+#define V_RENAME(oldname,newname) rename(oldname,newname)
 #define V_CHDIR(path) chdir(path)
 #define V_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
 #define V_GETWD(buf) getwd(buf)