summaryrefslogtreecommitdiff
path: root/main/php_virtual_cwd.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-04-29 19:01:58 +0000
committerAndi Gutmans <andi@php.net>2000-04-29 19:01:58 +0000
commitf1d5167ae35f8d55dbdee8e255f2025d4fcfadfa (patch)
treef5050677262ecb4d1302642946a45de42a8dc095 /main/php_virtual_cwd.c
parent9e9ba7d974333171ecaa57e2c92b0e0ee0dc0b2a (diff)
downloadphp-git-f1d5167ae35f8d55dbdee8e255f2025d4fcfadfa.tar.gz
- Implement V_OPEN() V_OPEN_CREAT() and V_CREAT().
Next step is to substitute all open()'s and creat()'s in the PHP tree
Diffstat (limited to 'main/php_virtual_cwd.c')
-rw-r--r--main/php_virtual_cwd.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c
index bef4c503fe..5aa3ba86f9 100644
--- a/main/php_virtual_cwd.c
+++ b/main/php_virtual_cwd.c
@@ -6,6 +6,11 @@
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
+#include <fcntl.h>
+
+#ifdef ZEND_WIN32
+#include "win95nt.h"
+#endif
#include "php_virtual_cwd.h"
@@ -388,6 +393,49 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode)
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)
{
cwd_state new_state;