Added getsize(), getmtime(), getatime()

This commit is contained in:
Guido van Rossum 1998-07-24 20:49:26 +00:00
parent 89a79d19b7
commit 2bc1f8f07e
4 changed files with 72 additions and 0 deletions

View file

@ -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.