cvs: php4 /main php.h php_virtual_cwd.c php_virtual_cwd.h

From: Date: Sun, 20 Aug 2000 12:49:57 +0000
Subject: cvs: php4 /main php.h php_virtual_cwd.c php_virtual_cwd.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1253@lists.php.net to get a copy of this message
sas Sun Aug 20 05:49:57 2000 EDT Modified files: /php4/main php_virtual_cwd.c php_virtual_cwd.h php.h Log: Add virtual_real_chdir_file. Silly name for a useful function. Index: php4/main/php_virtual_cwd.c diff -u php4/main/php_virtual_cwd.c:1.66 php4/main/php_virtual_cwd.c:1.67 --- php4/main/php_virtual_cwd.c:1.66 Tue Aug 8 09:30:42 2000 +++ php4/main/php_virtual_cwd.c Sun Aug 20 05:49:56 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_virtual_cwd.c,v 1.66 2000/08/08 16:30:42 stas Exp $ */ +/* $Id: php_virtual_cwd.c,v 1.67 2000/08/20 12:49:56 sas Exp $ */ #include <sys/types.h> #include <sys/stat.h> @@ -744,6 +744,26 @@ } #endif + +/* taken from Apache 1.3 */ + +CWD_API void virtual_real_chdir_file(const char *file) +{ + const char *x; + char buf[4096]; + + x = strrchr(file, '/'); + if (x == NULL) { + chdir(file); + } + else if (x - file < sizeof(buf) - 1) { + memcpy(buf, file, x - file); + buf[x - file] = '\0'; + chdir(buf); + } + /* XXX: well, this is a silly function, no method of reporting an + * error... ah well. */ +} #if 0 Index: php4/main/php_virtual_cwd.h diff -u php4/main/php_virtual_cwd.h:1.32 php4/main/php_virtual_cwd.h:1.33 --- php4/main/php_virtual_cwd.h:1.32 Sun Aug 6 11:14:46 2000 +++ php4/main/php_virtual_cwd.h Sun Aug 20 05:49:56 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_virtual_cwd.h,v 1.32 2000/08/06 18:14:46 sas Exp $ */ +/* $Id: php_virtual_cwd.h,v 1.33 2000/08/20 12:49:56 sas Exp $ */ #ifndef VIRTUAL_CWD_H #define VIRTUAL_CWD_H @@ -78,6 +78,7 @@ CWD_API char *virtual_getcwd(char *buf, size_t size); CWD_API int virtual_chdir(char *path); CWD_API int virtual_chdir_file(char *path); +CWD_API int virtual_real_chdir_file(char *path); CWD_API int virtual_filepath(char *path, char **filepath); CWD_API char *virtual_realpath(char *path, char *real_path); CWD_API FILE *virtual_fopen(const char *path, const char *mode); Index: php4/main/php.h diff -u php4/main/php.h:1.111 php4/main/php.h:1.112 --- php4/main/php.h:1.111 Thu Aug 10 12:38:28 2000 +++ php4/main/php.h Sun Aug 20 05:49:56 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.111 2000/08/10 19:38:28 andi Exp $ */ +/* $Id: php.h,v 1.112 2000/08/20 12:49:56 sas Exp $ */ #ifndef PHP_H #define PHP_H @@ -324,7 +324,7 @@ #define V_OPEN(open_args) open open_args #define V_CREAT(path, mode) creat(path, mode) #define V_CHDIR(path) chdir(path) -#define V_CHDIR_FILE(path) chdir_file(path) +#define V_CHDIR_FILE(path) virtual_real_chdir_file(path) #define V_GETWD(buf) getwd(buf) #define V_STAT(path, buff) stat(path, buff) #define V_LSTAT(path, buff) lstat(path, buff)

« previous php.cvs (#1253) next »