cvs: /php4 php_virtual_cwd.c
| From: | Andi Gutmans | Date: | Sun, 19 Mar 2000 21:11:18 +0000 |
| Subject: | cvs: /php4 php_virtual_cwd.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12415@lists.php.net to get a copy of this message | ||
andi Sun Mar 19 13:11:18 2000 EDT
Modified files:
/php4 php_virtual_cwd.c
Log:
- Quick fopen() support. The code needs some cleaning up and we might
need to think of performance issues with the strdup()'s (definitely
use strndup() and maybe try to do with less string copies).
Index: php4/php_virtual_cwd.c
diff -u php4/php_virtual_cwd.c:1.12 php4/php_virtual_cwd.c:1.13
--- php4/php_virtual_cwd.c:1.12 Fri Mar 17 02:25:23 2000
+++ php4/php_virtual_cwd.c Sun Mar 19 13:10:48 2000
@@ -226,9 +226,32 @@
return virtual_file_ex(state, path, NULL); /* Use NULL right now instead of php_is_dir_ok */
}
-int virtual_filepath(cwd_state *state, char *path)
+int virtual_filepath(cwd_state *state, char *path, char **filepath)
{
- return virtual_file_ex(state, path, php_is_file_ok);
+ cwd_state new_state = *state;
+ int retval;
+
+ new_state.cwd = strdup(state->cwd);
+ retval = virtual_file_ex(&new_state, path, php_is_file_ok);
+ *filepath = new_state.cwd;
+ return retval;
+}
+
+FILE *virtual_fopen(cwd_state *state, char *path, const char *mode)
+{
+ cwd_state new_state = *state;
+ FILE *f;
+ int retval;
+
+ new_state.cwd = strdup(state->cwd);
+ retval = virtual_file_ex(&new_state, path, php_is_file_ok);
+
+ if (retval) {
+ return NULL;
+ }
+ f = fopen(new_state.cwd, mode);
+ free(new_state.cwd);
+ return f;
}
main(void)