[issue10027] os.lstat/os.stat don't set st_nlink on Windows

Hirokazu Yamamoto report at bugs.python.org
Wed Oct 6 13:47:51 CEST 2010


Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:

There are some questions.

1. About my patch, I noticed it removed following code.
   Isn't this needed? I like clean code, but I don't want to
   break anything.

    /* Get WIN32_FIND_DATA structure for the path to determine if
       it is a symlink */
    if(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
        find_data_handle = FindFirstFileA(path, &find_data);
        if(find_data_handle != INVALID_HANDLE_VALUE) {
            if(find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
                /* first clear the S_IFMT bits */
                result->st_mode ^= (result->st_mode & 0170000);
                /* now set the bits that make this a symlink */
                result->st_mode |= 0120000;
            }
            FindClose(find_data_handle);
        }
    }


    /* Set S_IFEXEC if it is an .exe, .bat, ... */
    dot = strrchr(path, '.');
    if (dot) {
        if (stricmp(dot, ".bat") == 0 || stricmp(dot, ".cmd") == 0 ||
            stricmp(dot, ".exe") == 0 || stricmp(dot, ".com") == 0)
            result->st_mode |= 0111;
    }

2. About current behavior. when os.stat() is used for junction
   (reparse point, but not simlink), returned information is
   about junction on XP or earlier, but about target folder on
   Vista or above. Is this intended bahavior?

Thank you.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10027>
_______________________________________


More information about the Python-bugs-list mailing list