I tend to prefer adding isjunction instead of changing ismount since I tend to not think about junctions as being mounts (but closer to symlinks).. but I guess either way the closeness of the concepts is a different story than the specific ask here. In other words: for clarity, adding a specific method makes the most sense to me.
On Mon, Nov 7, 2022, 5:53 PM Eryk Sun <eryk...@gmail.com> wrote: > On 11/7/22, Charles Machalow <csm10...@gmail.com> wrote: > > So would you be for specific methods to check if a given path is a > > junction? > > I'd prefer for ismount() to be modified to always return true for a > junction. This would be a significant rewrite of the current > implementation, which is only true for a junction that targets a > system volume mount point (i.e. "\\?\Volume{GUID}\"). Of course > ismount() wouldn't be true for only junctions. It's also be true for > the root path of any drive, device, or UNC share if it's an existing > filesystem directory. > > Implementing a function that checks for only a junction is simple > enough. For example: > > def isjunction(path): > """Test whether a path is a junction. > """ > try: > st = os.lstat(path) > except (OSError, ValueError, AttributeError): > return False > return bool(st.st_reparse_tag & stat.IO_REPARSE_TAG_MOUNT_POINT) > > To be completely certain, sometimes st_file_attributes is also checked > for stat.FILE_ATTRIBUTE_REPARSE_POINT. But a filesystem that sets a > reparse point on a directory without also setting the latter file > attribute would be dysfunctional. >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/LHYQYTU7632ERC5EJJBVL3BQFLIFC3E7/ Code of Conduct: http://python.org/psf/codeofconduct/