mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Use 'stat' module instead of hardcoding information from <sys/stat.h>.
This commit is contained in:
parent
6b47ed1f9d
commit
40d9304d66
4 changed files with 17 additions and 36 deletions
|
@ -1,6 +1,7 @@
|
|||
# Module 'path' -- common operations on POSIX pathnames
|
||||
|
||||
import posix
|
||||
import stat
|
||||
|
||||
|
||||
# Intelligent pathname concatenation.
|
||||
|
@ -63,7 +64,7 @@ def isdir(path):
|
|||
st = posix.stat(path)
|
||||
except posix.error:
|
||||
return 0
|
||||
return st[0] / 4096 = 4 # S_IFDIR
|
||||
return stat.S_ISDIR(st[stat.ST_MODE])
|
||||
|
||||
|
||||
# Is a path a symbolic link?
|
||||
|
@ -74,7 +75,7 @@ def islink(path):
|
|||
st = posix.lstat(path)
|
||||
except (posix.error, NameError):
|
||||
return 0
|
||||
return st[0] / 4096 = 10 # S_IFLNK
|
||||
return stat.S_ISLNK(st[stat.ST_MODE])
|
||||
|
||||
|
||||
_mounts = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue