]> granicus.if.org Git - php/commitdiff
- Quick fopen() support. The code needs some cleaning up and we might
authorAndi Gutmans <andi@php.net>
Sun, 19 Mar 2000 21:10:48 +0000 (21:10 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 19 Mar 2000 21:10:48 +0000 (21:10 +0000)
  need to think of performance issues with the strdup()'s (definitely
  use strndup() and maybe try to do with less string copies).

main/php_virtual_cwd.c

index c3bd9ae0dfd516ecbd696c6cff56f96a717dbbf5..a4583fdca1cee5bad051d5cefb9d13c4f1872e27 100644 (file)
@@ -226,9 +226,32 @@ int virtual_chdir(cwd_state *state, char *path)
        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)