硬汉嵌入式论坛

 找回密码
 立即注册
查看: 137|回复: 2
收起左侧

[RL-FlashFS] 关于RLFS文件系统,文件时间的问题

[复制链接]

20

主题

94

回帖

154

积分

初级会员

积分
154
发表于 2024-4-22 23:59:20 | 显示全部楼层 |阅读模式
按照文档,使用如下函数设置文件的时间,获取文件时间。

设置文件时间代码:


[C] 纯文本查看 复制代码
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");
  }
}


查看文件时间代码
[C] 纯文本查看 复制代码
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卡拔出来,插到电脑上看,文件时间就不对了。时间也看不出什么规律来。这是什么问题?

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106904
QQ
发表于 2024-4-23 08:15:17 | 显示全部楼层
没测试过这个函数,后面有时间了试试。
回复

使用道具 举报

12

主题

178

回帖

214

积分

高级会员

积分
214
发表于 2024-5-1 22:21:08 来自手机 | 显示全部楼层
试试先用fclose关掉文件,再设置ftime_set
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-9 10:57 , Processed in 0.153047 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表