Issue 7566: Add ntpath.sameopenfile support for Windows (original) (raw)

Created on 2009-12-23 00:56 by jaraco, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7566.diff brian.curtin,2010-07-23 19:50
Messages (5)
msg96822 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-12-23 00:56
In , asvetlov suggests adding an implementation of os.sameopenfile to ntpath.py: --- Jason, as I see you implemented os.samefile (actually ntpath.samefile) but os.sameopenfile is still not implemented. Looks like it's easy to do: while GetFinalPathNameByHandle already accept file handle you can use CRT function _get_osfhandle(fd) to convert file descriptors (arguments for sameopenfile) to file handles and pass it to GetFinalPathNameByHandle. For me samefile and sameopenfile has very close semantic and I like to see both if it's possible. --- This seems entirely reasonable, but I would like to track and tackle this as a separate issue.
msg96828 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-12-23 02:07
As NTFS supports hard links, I think GetFileInformationByHandle should be used to compare handles (looking at dwVolumeSerialNumber, nFileIndexHigh,nFileIndexLow)
msg96841 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-12-23 15:54
That's an excellent idea. I had searched briefly for a more correct solution, but did not find one at the time.
msg111377 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-07-23 19:50
Here's a patch implementing ntpath.sameopenfile with _getfileinformation in Modules/posixmodule.c. Martin's suggestion is the best way of doing this, which was the basis for _getfileinformation implementation. It returns a tuple of the three relevant fields, and ntpath.sameopenfile compares the results of those tuples for two files and returns the result.
msg115717 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-09-06 17:08
Added in r84561.
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51815
2010-09-06 17:08:09 brian.curtin set status: open -> closedresolution: fixedmessages: + stage: needs patch -> resolved
2010-07-23 19:50:13 brian.curtin set files: + issue7566.diffkeywords: + patchmessages: +
2010-07-23 15:06:25 brian.curtin link issue8879 dependencies
2010-06-28 00:14:06 brian.curtin set assignee: brian.curtinnosy: + brian.curtinstage: needs patch
2010-02-16 18:02:15 akrpic77 set nosy: + akrpic77components: - Library (Lib)versions: - Python 2.7
2010-02-16 03:55:42 brian.curtin set components: + Library (Lib)versions: + Python 2.7
2009-12-29 12:03:59 asvetlov set nosy: + asvetlov
2009-12-23 16:23:08 eric.smith set nosy: + eric.smith
2009-12-23 15:54:13 jaraco set messages: +
2009-12-23 02:07:04 loewis set nosy: + loewismessages: +
2009-12-23 00:56:46 jaraco create