在 C 中使用 utime 获取 UNIX 上的文件修改时间
一位教授告诉我,您可以使用utime.h获取文件的最后修改时间。然而,手册页似乎引用了 utime() 仅设置此值。如何在 UNIX 系统上的 C 语言中查找文件上次更改的时间?
I have been told by a professor that you can get a file's last modification time by using utime.h. However, the man page seem to cite that utime() only sets this value. How can I look up the last time a file was changed in C on a UNIX system?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将返回文件的mtime,即“上次数据修改的时间”。请注意,Unix 也有一个概念ctime ,“上次状态更改的时间”(另请参阅 ctime、atime、mtime )。
This returns the file's mtime, the "time of last data modification". Note that Unix also has a concept ctime, the "time of last status change" (see also ctime, atime, mtime).
您可以使用 stat 系统调用来获取最后访问和修改时间。
You can use the stat system call to get the last access and modification times.