mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)
This commit is contained in:
parent
c2276176d5
commit
0821923aa9
5 changed files with 39 additions and 57 deletions
|
@ -7,8 +7,8 @@ import os
|
|||
import stat
|
||||
|
||||
__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
|
||||
'getsize', 'isdir', 'isfile', 'islink', 'samefile', 'sameopenfile',
|
||||
'samestat']
|
||||
'getsize', 'isdevdrive', 'isdir', 'isfile', 'isjunction', 'islink',
|
||||
'lexists', 'samefile', 'sameopenfile', 'samestat']
|
||||
|
||||
|
||||
# Does a path exist?
|
||||
|
@ -22,6 +22,15 @@ def exists(path):
|
|||
return True
|
||||
|
||||
|
||||
# Being true for dangling symbolic links is also useful.
|
||||
def lexists(path):
|
||||
"""Test whether a path exists. Returns True for broken symbolic links"""
|
||||
try:
|
||||
os.lstat(path)
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
return True
|
||||
|
||||
# This follows symbolic links, so both islink() and isdir() can be true
|
||||
# for the same path on systems that support symlinks
|
||||
def isfile(path):
|
||||
|
@ -57,6 +66,21 @@ def islink(path):
|
|||
return stat.S_ISLNK(st.st_mode)
|
||||
|
||||
|
||||
# Is a path a junction?
|
||||
def isjunction(path):
|
||||
"""Test whether a path is a junction
|
||||
Junctions are not supported on the current platform"""
|
||||
os.fspath(path)
|
||||
return False
|
||||
|
||||
|
||||
def isdevdrive(path):
|
||||
"""Determines whether the specified path is on a Windows Dev Drive.
|
||||
Dev Drives are not supported on the current platform"""
|
||||
os.fspath(path)
|
||||
return False
|
||||
|
||||
|
||||
def getsize(filename):
|
||||
"""Return the size of a file, reported by os.stat()."""
|
||||
return os.stat(filename).st_size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue