From: Anantha Kesari H Y Date: Thu, 7 Jul 2005 07:32:57 +0000 (+0000) Subject: 1)gwtcwd of NetWare LibC gives a cwd with a volume information. X-Git-Tag: php-5.0.5RC1~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff870e61497610a269623dc23b4421b4956775e8;p=php 1)gwtcwd of NetWare LibC gives a cwd with a volume information. So using getcwdpath which gives with volume information. getcwdpath gives with directory seperator as \ which is against our DEFAULT_SLASH of /. So finding and replacing \ with / 2)NetWare file path normalization code in virtual_file_ex. -- Kamesh --- diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index ee8262495f..898985a3a0 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -42,8 +42,7 @@ #endif #ifdef NETWARE -/*#include "pipe.h"*/ -#include "tsrm_nw.h" +#include #endif #ifndef HAVE_REALPATH @@ -202,7 +201,20 @@ CWD_API void virtual_cwd_startup(void) char cwd[MAXPATHLEN]; char *result; +#ifdef NETWARE + result = getcwdpath(cwd, NULL, 1); + if(result) + { + char *c=cwd; + while(c = strchr(c, '\\')) + { + *c='/'; + ++c; + } + } +#else result = getcwd(cwd, sizeof(cwd)); +#endif if (!result) { cwd[0] = '\0'; } @@ -445,8 +457,19 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func state->cwd[state->cwd_length++] = DEFAULT_SLASH; } #elif defined(NETWARE) - /* If the token is a volume name, it will have colon at the end -- so, no slash before it */ - if (ptr[ptr_length-1] != ':') { + /* + Below code keeps appending to state->cwd a File system seperator + cases where this appending should not happen is given below, + a) sys: should just be left as it is + b) sys:system should just be left as it is, + Colon is allowed only in the first token as volume names alone can have the : in their names. + Files and Directories cannot have : in their names + So the check goes like this, + For second token and above simply append the DEFAULT_SLASH to the state->cwd. + For first token check for the existence of : + if it exists don't append the DEFAULT_SLASH to the state->cwd. + */ + if(((state->cwd_length == 0) && (strchr(ptr, ':') == NULL)) || (state->cwd_length > 0)) { state->cwd[state->cwd_length++] = DEFAULT_SLASH; } #else