]> granicus.if.org Git - python/commitdiff
Added getsize(), getmtime(), getatime()
authorGuido van Rossum <guido@python.org>
Fri, 24 Jul 1998 20:49:26 +0000 (20:49 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 Jul 1998 20:49:26 +0000 (20:49 +0000)
Lib/dospath.py
Lib/macpath.py
Lib/ntpath.py
Lib/posixpath.py

index 5dbda89540663bb1b0eee86c31b94e32cf99f850..a956c09269c989ab6f708e4b4fd7fcf4a23dacd3 100644 (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.
 
index eeed54168a5bac09f238c4bc92556c80700177b5..68dd6d48cc1389e992e05c6b405d2aba731d2344 100644 (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.)
 
index 7bec2f78687d982db0ddd2e6c4304d2f2f256d1f..ca7f3d105669e5d83b7e8a3db5c86940b7f4bb58 100644 (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.
 
index 1166881ffc0f021d36595212107d507a8d51598f..a5c0de2dad5e876dbe157d0851126beeab18a0df 100644 (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.