]> granicus.if.org Git - php/commitdiff
1)gwtcwd of NetWare LibC gives a cwd with a volume information.
authorAnantha Kesari H Y <hyanantha@php.net>
Thu, 7 Jul 2005 07:32:57 +0000 (07:32 +0000)
committerAnantha Kesari H Y <hyanantha@php.net>
Thu, 7 Jul 2005 07:32:57 +0000 (07:32 +0000)
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

TSRM/tsrm_virtual_cwd.c

index ee8262495f5f22c85f6f78e5267b5c03caf43667..898985a3a095c39e2e0b06f92f272b3103444738 100644 (file)
@@ -42,8 +42,7 @@
 #endif
 
 #ifdef NETWARE
-/*#include "pipe.h"*/
-#include "tsrm_nw.h"
+#include <fsio.h>
 #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