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

@ -124,6 +124,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.

View File

@ -99,6 +99,24 @@ def isdir(s):
return S_ISDIR(st[ST_MODE])
# 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]
# Return true if the pathname refers to a symbolic link.
# (Always false on the Mac, until we understand Aliases.)

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.

View File

@ -128,6 +128,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 os.lstat doesn't exist.