Eryk Sun added the comment:
Sample implementation:
import os
import msvcrt
import win32file
def samefile(f1, f2):
"""Test whether two paths refer to the same file or directory."""
s1 = os.stat(f1)
s2 = os.stat(f2)
return _common_same_file(f1,
Eryk Sun added the comment:
Python uses the volume serial number (VSN) and file ID for st_dev and st_ino.
The OS allows the file ID to be 0 if the filesystem doesn't support file IDs.
Also, it does not require or force the VSN to be a unique ID in the system,
though if it's not 0 it's
Nick Venenga added the comment:
This script can reproduce the issue.
The computer must be a Windows computer with volume shadow copy service enabled
The computer must have shadow storage added to the drive being used
This script changes the host machine by creating a shadow copy (permissions
New submission from Nick Venenga :
shutil.copy fails to copy a file from a shadow copy back to its original file
since os.path.samefile returns True. os.path.samefile doesn't reliably detect
these files are different since it relies on ino which is the same for both
files
>>> sc =
>>>