[issue5985] Implement os.path.samefile and os.path.sameopenfile on Windows

Erik Sandberg report at bugs.python.org
Wed Oct 14 13:22:51 CEST 2009


Erik Sandberg <sandberg at virtutech.com> added the comment:

An alternative solution which I would have considered, is to extend
stat/fstat on Windows to set st_dev and st_ino to sensible values (based
on dwVolumeSerialNumber and nFileIndexLow/High), and then use the POSIX
implementations of samefile/sameopenfile.

There may be one potential problem with this solution though: It would
require stat to perform a CreateFile in addition to GetFileAttributesEx,
and I don't know if there are situations where one is allowed to call
the latter but not the former on a file. There would be no such problems
with fstat, though.

In your patch, I think the dwShareMode parameter to CreateFile* should
be changed to FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE so
make the operation less intrusive.

----------

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


More information about the Python-bugs-list mailing list