diff options
| author | Andi Gutmans <andi@php.net> | 2000-04-01 18:21:03 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2000-04-01 18:21:03 +0000 |
| commit | 57b398af1f353b48d5bd20856b71b71fa9acf8b2 (patch) | |
| tree | 2e7f97f420dc9a07802150d7e41198a5b7dd2d91 | |
| parent | a73ba4b2383652c3ed061f40bd374891a24938be (diff) | |
| download | php-git-57b398af1f353b48d5bd20856b71b71fa9acf8b2.tar.gz | |
- More virtual_cwd work
| -rw-r--r-- | main/php_virtual_cwd.c | 26 | ||||
| -rw-r--r-- | main/php_virtual_cwd.h | 2 |
2 files changed, 25 insertions, 3 deletions
diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c index a09d9826a5..29fb4b9a00 100644 --- a/main/php_virtual_cwd.c +++ b/main/php_virtual_cwd.c @@ -16,6 +16,8 @@ CWD_API int cwd_globals_id; cwd_globals_struct cwd_globals; #endif +cwd_state true_global_cwd_state; + #ifndef PHP_WIN32 #include <unistd.h> #endif @@ -108,9 +110,29 @@ static int php_is_file_ok(const cwd_state *state) return (1); } -void virtual_cwd_init() +static void cwd_globals_ctor(cwd_globals_struct *cwd_globals) +{ + cwd_globals->cwd.cwd = (char *) malloc(true_global_cwd_state.cwd_length+1); + memcpy(cwd_globals->cwd.cwd, true_global_cwd_state.cwd, true_global_cwd_state.cwd_length+1); + cwd_globals->cwd.cwd_length = true_global_cwd_state.cwd_length; +} + +void virtual_cwd_startup() { - /* Initialize the true global cwd */ + char cwd[1024]; /* Should probably use system define here */ + char *result; + + result = getcwd(cwd, sizeof(cwd)); + if (!result) { + cwd[0] = '\0'; + } + true_global_cwd_state.cwd = strdup(cwd); + true_global_cwd_state.cwd_length = strlen(cwd); +#ifdef ZTS + cwd_globals_id = ts_allocate_id(sizeof(cwd_globals_struct), (ts_allocate_ctor) cwd_globals_ctor, NULL); +#else + cwd_globals_ctor(&cwd_globals); +#endif } char *virtual_getcwd_ex(int *length) diff --git a/main/php_virtual_cwd.h b/main/php_virtual_cwd.h index 42149ebdac..9b1d3aad71 100644 --- a/main/php_virtual_cwd.h +++ b/main/php_virtual_cwd.h @@ -20,7 +20,7 @@ typedef struct _cwd_state { typedef int (*verify_path_func)(const cwd_state *); -void virtual_cwd_init(); +void virtual_cwd_startup(); char *virtual_getcwd_ex(int *length); char *virtual_getcwd(char *buf, size_t size); int virtual_chdir(char *path); |
