]> granicus.if.org Git - php/commitdiff
- This version of chdir_file should be compatible with the Apache one.
authorAndi Gutmans <andi@php.net>
Sun, 2 Apr 2000 19:45:02 +0000 (19:45 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 2 Apr 2000 19:45:02 +0000 (19:45 +0000)
main/php.h
main/php_virtual_cwd.c
main/php_virtual_cwd.h
sapi/apache/mod_php4.c

index 76494cbdd81f05ae1fa33730972a0dbb27f821b7..5e1d8d84ddac0b6e6cf912dc43026d2c91b9eb2b 100644 (file)
@@ -291,11 +291,13 @@ PHPAPI int cfg_get_string(char *varname, char **result);
 #define PHP_GETCWD(buff, size) virtual_getcwd(buff,size)
 #define PHP_FOPEN(path, mode) virtual_fopen(path, mode)
 #define PHP_CHDIR(path) virtual_chdir(path)
+#define PHP_CHDIR_FILE(path) virtual_chdir_file(path)
 #define PHP_GETWD(buf)
 #else
 #define PHP_GETCWD(buff, size) getcwd(buff,size)
 #define PHP_FOPEN(path, mode)  fopen(path, mode)
 #define PHP_CHDIR(path) chdir(path)
+#define PHP_CHDIR_FILE(path) chdir_file(path)
 #define PHP_GETWD(buf) getwd(buf)
 #endif
 
index 820db5ce40954a9a454608d45490ba2db81d9189..470c28a2b36c9b5919c77ae5db13de4666b66474 100644 (file)
@@ -286,6 +286,24 @@ int virtual_chdir(char *path)
        return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok);
 }
 
+int virtual_chdir_file(char *path)
+{
+       int length = strlen(path);
+
+       if (length == 0) {
+               return 1; /* Can't CD to empty string */
+       }       
+       while(--length >= 0 && !IS_SLASH(path[length])) {
+       }
+
+       if (length == -1) {
+               return virtual_chdir(path);
+       }
+       path[length] = DEFAULT_SLASH;
+       return virtual_chdir(path);
+}
+
+
 int virtual_filepath(char *path, char **filepath)
 {
        cwd_state new_state;
index 8b4f40a9dc5caa9baa866421d7ef0d34b147e02b..e98bb5344cc92557028d1552302b9241d5f6f359 100644 (file)
@@ -25,6 +25,7 @@ void virtual_cwd_startup();
 char *virtual_getcwd_ex(int *length);
 char *virtual_getcwd(char *buf, size_t size);
 int virtual_chdir(char *path);
+int virtual_chdir_file(char *path);
 int virtual_filepath(char *path, char **filepath);
 FILE *virtual_fopen(char *path, const char *mode);
 
index 328e179080af5eaa4bec397110c5513dd7119346..fe062e08eb0ad56509607f794eb787c5660b7289 100644 (file)
@@ -483,7 +483,7 @@ int send_php(request_rec *r, int display_source_mode, char *filename)
        SG(server_context) = r;
        
        php_save_umask();
-       chdir_file(filename);
+       PHP_CHDIR_FILE(filename);
        add_common_vars(r);
        add_cgi_vars(r);