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

From: Date: Sat, 29 Apr 2000 19:02:29 +0000
Subject: cvs: /php4 php.h php_virtual_cwd.c php_virtual_cwd.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-14178@lists.php.net to get a copy of this message
andi Sat Apr 29 12:02:29 2000 EDT Modified files: /php4 php.h php_virtual_cwd.c php_virtual_cwd.h Log: - Implement V_OPEN() V_OPEN_CREAT() and V_CREAT(). Next step is to substitute all open()'s and creat()'s in the PHP tree Index: php4/php.h diff -u php4/php.h:1.89 php4/php.h:1.90 --- php4/php.h:1.89 Sat Apr 29 10:57:47 2000 +++ php4/php.h Sat Apr 29 12:01:58 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.89 2000/04/29 17:57:47 zeev Exp $ */ +/* $Id: php.h,v 1.90 2000/04/29 19:01:58 andi Exp $ */ #ifndef _PHP_H #define _PHP_H @@ -298,6 +298,9 @@ #ifdef VIRTUAL_DIR #define V_GETCWD(buff, size) virtual_getcwd(buff,size) #define V_FOPEN(path, mode) virtual_fopen(path, mode) +#define V_OPEN(path, flags) virtual_open(path, flags) +#define V_OPEN_CREAT(path, flags, mode) virtual_open(path, flags, mode) +#define V_CREAT(path, mode) virtual_creat(path, mode) #define V_CHDIR(path) virtual_chdir(path) #define V_CHDIR_FILE(path) virtual_chdir_file(path) #define V_GETWD(buf) @@ -310,6 +313,9 @@ #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) +#define V_OPEN(path, flags) open(path, flags) +#define V_OPEN_CREAT(path, flags, mode) open(path, flags, mode) +#define V_CREAT(path, mode) creat(path, mode) #define V_CHDIR(path) chdir(path) #define V_CHDIR_FILE(path) chdir_file(path) #define V_GETWD(buf) getwd(buf) Index: php4/php_virtual_cwd.c diff -u php4/php_virtual_cwd.c:1.37 php4/php_virtual_cwd.c:1.38 --- php4/php_virtual_cwd.c:1.37 Fri Apr 21 07:50:09 2000 +++ php4/php_virtual_cwd.c Sat Apr 29 12:01:58 2000 @@ -6,7 +6,12 @@ #include <errno.h> #include <stdlib.h> #include <ctype.h> +#include <fcntl.h> +#ifdef ZEND_WIN32 +#include "win95nt.h" +#endif + #include "php_virtual_cwd.h" #define VIRTUAL_CWD_DEBUG 0 @@ -387,6 +392,49 @@ CWD_STATE_FREE(&new_state); return f; } + +CWD_API int virtual_open(const char *path, int flags) +{ + cwd_state new_state; + int f; + CWDLS_FETCH(); + + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + + virtual_file_ex(&new_state, path, NULL); + + if (flags & O_CREAT) { + mode_t mode; + va_list arg; + + va_start(arg, flags); + mode = va_arg(arg, mode_t); + va_end(arg); + + f = open(new_state.cwd, flags, mode); + } else { + f = open(new_state.cwd, flags); + } + CWD_STATE_FREE(&new_state); + return f; +} + +CWD_API int virtual_creat(const char *path, mode_t mode) +{ + cwd_state new_state; + int f; + CWDLS_FETCH(); + + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + + virtual_file_ex(&new_state, path, NULL); + + f = open(new_state.cwd, O_CREAT | O_TRUNC, mode); + + CWD_STATE_FREE(&new_state); + return f; +} + CWD_API int virtual_stat(const char *path, struct stat *buf) { Index: php4/php_virtual_cwd.h diff -u php4/php_virtual_cwd.h:1.15 php4/php_virtual_cwd.h:1.16 --- php4/php_virtual_cwd.h:1.15 Thu Apr 20 10:40:03 2000 +++ php4/php_virtual_cwd.h Sat Apr 29 12:01:58 2000 @@ -42,6 +42,8 @@ CWD_API int virtual_chdir_file(char *path); CWD_API int virtual_filepath(char *path, char **filepath); 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_stat(const char *path, struct stat *buf); #ifndef ZEND_WIN32 CWD_API int virtual_lstat(const char *path, struct stat *buf);

« previous php.version4 (#14178) next »