I am trying the following code:
os.stat(path_name)[stat.ST_CTIME] = ctime
However, this gives the following error:
exceptions.TypeError: 'posix.stat_result' object does not support item assignment
Is there anyway to modify ctime?
Thanks!
I am trying the following code:
os.stat(path_name)[stat.ST_CTIME] = ctime
However, this gives the following error:
exceptions.TypeError: 'posix.stat_result' object does not support item assignment
Is there anyway to modify ctime?
Thanks!
os.utime(filename, timetuple)
can be used to set the atime and mtime of a file. As far as I know there is no way to modify the ctime from userland without resorting to hacks such as playing with the clock or direct edition of the filesystem (which I really do not recommend), and this is true for any programming language (Python, Perl, C, C++...) : it's internal OS stuff, and you don't want to touch it.See for example in the documentation of the
touch
command (http://www.delorie.com/gnu/docs/fileutils/fileutils_54.html):GNU stroke implements the change-system-time trick to change ctime of a file. If that's what you want, GNU stroke does it for you: http://stroke.sourceforge.net/.
There is no direct way to set change time, it gets updated whenever inode information changes, like ownership, link count, mode, etc..
Try setting the mode to the already set mode: