关于RLFS文件系统,文件时间的问题
按照文档,使用如下函数设置文件的时间,获取文件时间。设置文件时间代码:
void set_timestamp (void) {
fsTime timedate;
// Set time and date
timedate.hr = 17;
timedate.min= 30;
timedate.sec= 2;
timedate.day= 25;
timedate.mon= 10;
timedate.year = 2019;
// Modify the timestamps
if (ftime_set ("file.txt", &timedate, &timedate, &timedate) == fsOK) {
printf ("File create, last access and last write time were successfully modified.\n");
}
else {
printf ("Failed to set the file timestamp.\n");
}
}
查看文件时间代码
void get_timestamp (void) {
fsTime create, access, write;
// Get the timestamps
if (ftime_get ("file.txt", &create, &access, &write) == fsOK) {
printf ("File create, last access and last write time were successfully retrieved.\n");
//Output the file create time and date information
printf ("Create Time: %d:%d:%d, %d.%d.%d\n", create.hr,create.min, create.sec, \
create.day, create.mon, create.year);
}
else {
printf ("Failed to get the file timestamp.\n");
}
}
这两个函数,运行printf的信息都是成功的,设置文件时间后,又重新打印文件时间,运行看到的结果都是正确的。
但是,把SD卡拔出来,插到电脑上看,文件时间就不对了。时间也看不出什么规律来。这是什么问题?
没测试过这个函数,后面有时间了试试。 试试先用fclose关掉文件,再设置ftime_set
页:
[1]