summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-09-06 17:07:27 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-09-06 17:07:27 (GMT)
commit6285774f06f44f04353801cc79fd2a5e67f884ec (patch)
treefd38bd421fce735854ca6de4bbe0774ba0769fe8 /Lib/ntpath.py
parent5c997b8d90e8e531bf844f5618a203f0a12ac9dc (diff)
downloadcpython-6285774f06f44f04353801cc79fd2a5e67f884ec.zip
cpython-6285774f06f44f04353801cc79fd2a5e67f884ec.tar.gz
cpython-6285774f06f44f04353801cc79fd2a5e67f884ec.tar.bz2
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.
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index ee7ac67..eae3cf3 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -10,6 +10,7 @@ import sys
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 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"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 @@ def samefile(f1, f2):
# 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)