os.utime

Christian Heimes lists at cheimes.de
Sun Mar 20 20:48:19 EDT 2011


Am 21.03.2011 00:52, schrieb monkeys paw:
> I used os.uname to succesfully change the access and mod times of
> a file. My question is, is there any other date store for a file that
> indicates the creation time, or is it impossible to detect that a file
> with an older mod/access time is actually a 'new' file?
> 
> os.utime('sum.py', (time.time(),time.time())

In general POSIX OS don't have the means to store and return the
creation time of a file. Although os.stat() returns a struct that
contains st_ctime, it's NOT the creation time stamp. Often people
confuse the 'c' in st_ctime for creation time. It's the last status
change, e.g. change of ownership. Some file system may store the
creation time stamp but I know of no cross platform way to query the
information. Windows and NTFS are a whole different beast. AFAIR NTFS
has a creation time stamp.

Christian




More information about the Python-list mailing list