diff Lib/ntpath.py @ 64495:f6dfd6c563e1

Implement #7566 - os.path.sameopenfile for Windows. This uses the GetFileInformationByHandle function to return a tuple of values to identify a file, then ntpath.sameopenfile compares file tuples, which is exposed as os.path.sameopenfile.
author Brian Curtin <brian.curtin@gmail.com>
date Mon, 06 Sep 2010 17:07:27 +0000
parents 6f5ba71316e7
children 541338795950
line wrap: on
line diff
--- a/Lib/ntpath.py	Mon Sep 06 16:29:29 2010 +0000
+++ b/Lib/ntpath.py	Mon Sep 06 17:07:27 2010 +0000
@@ -10,6 +10,7 @@
 import stat
 import genericpath
 from genericpath import *
+from nt import _getfileinformation
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
            "basename","dirname","commonprefix","getsize","getmtime",
@@ -17,7 +18,7 @@
            "ismount", "expanduser","expandvars","normpath","abspath",
            "splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
            "extsep","devnull","realpath","supports_unicode_filenames","relpath",
-           "samefile",]
+           "samefile", "sameopenfile",]
 
 # strings representing various path-related bits and pieces
 # These are primarily for export; internally, they are hardcoded.
@@ -652,3 +653,7 @@
         # Also, on other operating systems, fake this method with a
         #  Windows-XP approximation.
         return abspath(f1) == abspath(f2)
+
+def sameopenfile(f1, f2):
+    """Test whether two file objects reference the same file"""
+    return _getfileinformation(f1) == _getfileinformation(f2)