]> granicus.if.org Git - php/commitdiff
removed redundant NEW_LIBC checks and added the code to recognize the file naming...
authorAnantha Kesari H Y <hyanantha@php.net>
Fri, 8 Oct 2004 08:59:11 +0000 (08:59 +0000)
committerAnantha Kesari H Y <hyanantha@php.net>
Fri, 8 Oct 2004 08:59:11 +0000 (08:59 +0000)
TSRM/tsrm_virtual_cwd.c

index fbdd1c0fd49ac21b579b802961b6ea19e1a7e5c0..67e9127ed47c2cfe8a502e8d924769673158b7f1 100644 (file)
 # endif
 #endif
 
-#ifdef NETWARE
-/*#include "pipe.h"*/
-#include "tsrm_nw.h"
-#endif
-
 #ifndef HAVE_REALPATH
 #define realpath(x,y) strcpy(y,x)
 #endif
@@ -143,15 +138,9 @@ static int php_check_dots(const char *element, int n)
        
 static int php_is_dir_ok(const cwd_state *state) 
 {
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
        struct stat buf;
 
        if (stat(state->cwd, &buf) == 0 && S_ISDIR(buf.st_mode))
-#else
-    struct stat_libc buf;
-
-    if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISDIR(buf.st_mode))
-#endif
                return (0);
 
        return (1);
@@ -159,15 +148,9 @@ static int php_is_dir_ok(const cwd_state *state)
 
 static int php_is_file_ok(const cwd_state *state) 
 {
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
        struct stat buf;
 
        if (stat(state->cwd, &buf) == 0 && S_ISREG(buf.st_mode))
-#else
-    struct stat_libc buf;
-
-    if (stat(state->cwd, (struct stat*)(&buf)) == 0 && S_ISREG(buf.st_mode))
-#endif
                return (0);
 
        return (1);
@@ -547,8 +530,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
@@ -822,7 +816,6 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC)
        return retval;
 }
 
-#if !(defined(NETWARE) && defined(CLIB_STAT_PATCH))
 CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
 {
        cwd_state new_state;
@@ -836,21 +829,6 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC)
        CWD_STATE_FREE(&new_state);
        return retval;
 }
-#else
-CWD_API int virtual_stat(const char *path, struct stat_libc *buf TSRMLS_DC)
-{
-       cwd_state new_state;
-       int retval;
-
-       CWD_STATE_COPY(&new_state, &CWDG(cwd));
-       virtual_file_ex(&new_state, path, NULL, 1);
-
-       retval = stat(new_state.cwd, (struct stat*)buf);
-
-       CWD_STATE_FREE(&new_state);
-       return retval;
-}
-#endif
 
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
 CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC)