我正在打开几个文件,并想在我的结构中添加文件的创建时间和最后一次写入时间。有什么办法可以做到吗?
			
			1030 次
		
2 回答
            3        
        
		
您可以使用fstat来读取上次写入时间(请参阅参考资料stat.st_mtime)。
我不知道读取创建时间的便携方式。在 Windows 上,您可以使用GetFileTime
于 2012-11-01T09:20:31.643   回答
    
    
            2        
        
		
使用stat().
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *path, struct stat *buf);
struct stat包含几个描述时间和日期信息的字段,特别是
time_t    st_atime;   /* time of last access */
time_t    st_mtime;   /* time of last modification */
time_t    st_ctime;   /* time of last status change */
于 2012-11-01T09:19:35.050   回答