- 主题:修改文件的创建日期要用哪个 API?
utimensat() 只能修改 modified 和 access 两个时间,不能修改创建时间。
想在备份的时候把创建日期也备份起来。
顺便问一下,utimensat() 的参数是结构体 struct timespec,其中的 tv_nsec 字段转换秒小数点后面的数字吗?
double t = seconds_since_epoch();
struct timespec times[2];
times[0].tv_sec = (uint) t;
times[0].tv_nsec = (t - (uint) t * 1.0) * 1000 * 1000 * 1000;
这样写对吗?
找了 stackoverflow 上面都是从文件系统直接取值,而没有赋值的示例。
--
FROM 47.243.39.*
文件有创建日期、修改日期和最后访问日期三个时间戳。
【 在 JulyClyde (我的月份又来了) 的大作中提到: 】
: 什么叫创建日期?
--
FROM 47.243.39.*
没有 change time 吧。是 mtime, modified.
ctime 确实是 created time. 但是目前看起来没有 API 可以修改。
【 在 JulyClyde (我的月份又来了) 的大作中提到: 】
: ctime是change time吧,不是create time
--
FROM 47.243.39.*
我看 win32api 有这个功能,所以问一下,unix 底下对应的 API 是啥。
BOOL SetFileTime(
[in] HANDLE hFile,
[in, optional] const FILETIME *lpCreationTime,
[in, optional] const FILETIME *lpLastAccessTime,
[in, optional] const FILETIME *lpLastWriteTime
);
【 在 Qlala (Qlala) 的大作中提到: 】
: 创建时间改了的话 这个标签还有什么意义?
--
FROM 47.243.39.*
原来如此!
【 在 gameplayer (*.*) 的大作中提到: 】
: ctime是change time, creation是btime,man statx或者man inode:
: /* The following fields are file timestamps */
: struct statx_timestamp stx_atime; /* Last access */
: ...................
--
FROM 47.243.39.*