]> granicus.if.org Git - php/commitdiff
Improved readlink, supress \??\ and use the drive syntax only
authorPierre Joye <pajoye@php.net>
Tue, 25 Aug 2009 23:51:04 +0000 (23:51 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 25 Aug 2009 23:51:04 +0000 (23:51 +0000)
ext/standard/link_win32.c

index 6fa65caaa41e3b8741474dc5a6a84bfe91557166..bd37aab306a3af53810525c5737cc4864775f1e5 100644 (file)
@@ -106,7 +106,7 @@ PHP_FUNCTION(readlink)
                        RETURN_FALSE;
        }
 
-       dwRet = pGetFinalPathNameByHandle(hFile, Path, MAXPATHLEN, VOLUME_NAME_NT);
+       dwRet = pGetFinalPathNameByHandle(hFile, Path, MAXPATHLEN, VOLUME_NAME_DOS);
        if(dwRet >= MAXPATHLEN) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't resolve the full path, the path exceeds the MAX_PATH_LEN (%d) limit", MAXPATHLEN);
                RETURN_FALSE;
@@ -117,7 +117,14 @@ PHP_FUNCTION(readlink)
        /* Append NULL to the end of the string */
        Path[dwRet] = '\0';
 
-       RETURN_STRING(Path, 1);
+       if(dwRet > 4) {
+               /* Skip first 4 characters if they are "\??\" */
+               if(Path[0] == '\\' && Path[0] == '\\' && Path[1] == '?' && Path[2] == '?' && Path[3] ==  '\\') {
+                       RETURN_STRING(Path + 4, 1);
+               }
+       } else {
+               RETURN_STRING(Path, 1);
+       }
 }
 /* }}} */