Patch #658927: Add getctime to os.path.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 31 Dec 2002 13:11:54 +0000 (13:11 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 31 Dec 2002 13:11:54 +0000 (13:11 +0000)
Document that getatime and getmtime may return floats.

Doc/lib/libposixpath.tex
Lib/macpath.py
Lib/ntpath.py
Lib/os2emxpath.py
Lib/posixpath.py
Misc/NEWS

index 78256390b7c4794863973a5a5fb2e4cc4facd82e..b83eff4a87e41abdb1f2839fc9b79ce981ee1bf0 100644 (file)
@@ -67,18 +67,28 @@ unchanged.
 
 \begin{funcdesc}{getatime}{path}
 Return the time of last access of \var{filename}.  The return
-value is integer giving the number of seconds since the epoch (see the 
+value is a number giving the number of seconds since the epoch (see the 
 \refmodule{time} module).  Raise \exception{os.error} if the file does
 not exist or is inaccessible.
 \versionadded{1.5.2}
+\versionchanged[If \function{os.stat_float_times()} returns True, the result is a floating point number]{2.3}
 \end{funcdesc}
 
 \begin{funcdesc}{getmtime}{path}
 Return the time of last modification of \var{filename}.  The return
-value is integer giving the number of seconds since the epoch (see the 
+value is a number giving the number of seconds since the epoch (see the 
 \refmodule{time} module).  Raise \exception{os.error} if the file does
 not exist or is inaccessible.
 \versionadded{1.5.2}
+\versionchanged[If \function{os.stat_float_times()} returns True, the result is a floating point number]{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{getctime}{path}
+Return the time of creation of \var{filename}.  The return
+value is a number giving the number of seconds since the epoch (see the 
+\refmodule{time} module).  Raise \exception{os.error} if the file does
+not exist or is inaccessible.
+\versionadded{2.3}
 \end{funcdesc}
 
 \begin{funcdesc}{getsize}{path}
index 734bae292edce39a5dc30e191e0fe4d83e4fceac..ba9d40b74361d2db5204d290d58413b340e7c7c5 100644 (file)
@@ -5,7 +5,7 @@ from stat import *
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
            "basename","dirname","commonprefix","getsize","getmtime",
-           "getatime","islink","exists","isdir","isfile",
+           "getatime","getctime", "islink","exists","isdir","isfile",
            "walk","expanduser","expandvars","normpath","abspath",
            "supports_unicode_filenames"]
 
@@ -129,6 +129,9 @@ def isfile(s):
         return False
     return S_ISREG(st.st_mode)
 
+def getctime(filename):
+    """Return the creation time of a file, reported by os.stat()."""
+    return os.stat(filename).st_ctime
 
 def exists(s):
     """Return True if the pathname refers to an existing file or directory."""
index 4e7bb885a9fddbaf8aa79e27cc8e77a989105df7..d6b69208df4e870947c4a5ffef1eb5429ab3ef73 100644 (file)
@@ -11,7 +11,7 @@ import sys
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
            "basename","dirname","commonprefix","getsize","getmtime",
-           "getatime","islink","exists","isdir","isfile","ismount",
+           "getatime","getctime", "islink","exists","isdir","isfile","ismount",
            "walk","expanduser","expandvars","normpath","abspath","splitunc",
            "supports_unicode_filenames"]
 
@@ -220,6 +220,9 @@ def getatime(filename):
     """Return the last access time of a file, reported by os.stat()"""
     return os.stat(filename).st_atime
 
+def getctime(filename):
+    """Return the creation time of a file, reported by os.stat()."""
+    return os.stat(filename).st_ctime
 
 # Is a path a symbolic link?
 # This will always return false on systems where posix.lstat doesn't exist.
index 616d474c65c539bf6a3d2a2e304875ccb1a33b7c..0315da027fa4d7ac87c351ae0e8d7cd7be36882f 100644 (file)
@@ -10,7 +10,7 @@ import stat
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
            "basename","dirname","commonprefix","getsize","getmtime",
-           "getatime","islink","exists","isdir","isfile","ismount",
+           "getatime","getctime", "islink","exists","isdir","isfile","ismount",
            "walk","expanduser","expandvars","normpath","abspath","splitunc",
            "supports_unicode_filenames"]
 
@@ -186,6 +186,9 @@ def getatime(filename):
     """Return the last access time of a file, reported by os.stat()"""
     return os.stat(filename).st_atime
 
+def getctime(filename):
+    """Return the creation time of a file, reported by os.stat()."""
+    return os.stat(filename).st_ctime
 
 # Is a path a symbolic link?
 # This will always return false on systems where posix.lstat doesn't exist.
index 4a92f18cb91945b9107abb1636768a7d4c75616a..8da9fdaa8c21c15bcd7633da14f08644122b48bc 100644 (file)
@@ -15,7 +15,7 @@ import stat
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
            "basename","dirname","commonprefix","getsize","getmtime",
-           "getatime","islink","exists","isdir","isfile","ismount",
+           "getatime","getctime","islink","exists","isdir","isfile","ismount",
            "walk","expanduser","expandvars","normpath","abspath",
            "samefile","sameopenfile","samestat","supports_unicode_filenames"]
 
@@ -137,6 +137,9 @@ def getatime(filename):
     """Return the last access time of a file, reported by os.stat()."""
     return os.stat(filename).st_atime
 
+def getctime(filename):
+    """Return the creation time of a file, reported by os.stat()."""
+    return os.stat(filename).st_ctime
 
 # Is a path a symbolic link?
 # This will always return false on systems where os.lstat doesn't exist.
index a5dbd94930f91f7217f18f3ce21d1ea0cc713859..1efaf453c7b097df432d5a1b5ab065b73d7e7001 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -463,6 +463,8 @@ Extension modules
 Library
 -------
 
+- os.path exposes getctime.
+
 - unittest.py now has two additional methods called assertAlmostEqual()
   and failIfAlmostEqual().  They implement an approximate comparision
   by rounding the difference between the two arguments and comparing