When using os.stat() in Python, can I assume that st_ctime is always less then or equal to st_mtime? If not, why not?
The code will always run on Linux, but if there is
As @ketil says, ctime is updated when file metadata is changed.
One way this can change is that if you move a file from one directory to another. ctime will change, but not mtime.
touch test_file
mv test_file another_directory/
stat another_directory/test_file
gives
File: `another_directory/test_file'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 80ah/2058d Inode: 23183108 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1004/ agrimm) Gid: ( 1004/ agrimm)
Access: 2011-07-07 10:11:27.000000000 +1000
Modify: 2011-07-07 10:11:27.000000000 +1000
Change: 2011-07-07 10:11:43.000000000 +1000