mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
Added getsize(), getmtime(), getatime()
This commit is contained in:
parent
89a79d19b7
commit
2bc1f8f07e
4 changed files with 72 additions and 0 deletions
|
@ -143,6 +143,24 @@ def commonprefix(m):
|
|||
return prefix
|
||||
|
||||
|
||||
# Get size, mtime, atime of files.
|
||||
|
||||
def getsize(filename):
|
||||
"""Return the size of a file, reported by os.stat()."""
|
||||
st = os.stat(filename)
|
||||
return st[stat.ST_SIZE]
|
||||
|
||||
def getmtime(filename):
|
||||
"""Return the last modification time of a file, reported by os.stat()."""
|
||||
st = os.stat(filename)
|
||||
return st[stat.ST_MTIME]
|
||||
|
||||
def getatime(filename):
|
||||
"""Return the last access time of a file, reported by os.stat()."""
|
||||
st = os.stat(filename)
|
||||
return st[stat.ST_MTIME]
|
||||
|
||||
|
||||
# Is a path a symbolic link?
|
||||
# This will always return false on systems where posix.lstat doesn't exist.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue