summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/dircache.c29
-rw-r--r--firmware/common/file.c1
-rw-r--r--firmware/include/dircache.h1
3 files changed, 31 insertions, 0 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 97c58842d5..ab33d1213d 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -37,6 +37,10 @@
37#include "usb.h" 37#include "usb.h"
38#include "file.h" 38#include "file.h"
39#include "buffer.h" 39#include "buffer.h"
40#if CONFIG_RTC
41#include "time.h"
42#include "timefuncs.h"
43#endif
40 44
41/* Queue commands. */ 45/* Queue commands. */
42#define DIRCACHE_BUILD 1 46#define DIRCACHE_BUILD 1
@@ -956,6 +960,31 @@ void dircache_update_filesize(int fd, long newsize, long startcluster)
956 fd_bindings[fd]->size = newsize; 960 fd_bindings[fd]->size = newsize;
957 fd_bindings[fd]->startcluster = startcluster; 961 fd_bindings[fd]->startcluster = startcluster;
958} 962}
963void dircache_update_filetime(int fd)
964{
965#if CONFIG_RTC == 0
966 (void)fd;
967#else
968 short year;
969 struct tm *now = get_time();
970 if (!dircache_initialized || fd < 0)
971 return ;
972
973 if (fd_bindings[fd] == NULL)
974 {
975 logf("dircache fd access error");
976 dircache_initialized = false;
977 return ;
978 }
979 year = now->tm_year+1900-1980;
980 fd_bindings[fd]->wrtdate = (((year)&0x7f)<<9) |
981 (((now->tm_mon+1)&0xf)<<5) |
982 (((now->tm_mday)&0x1f));
983 fd_bindings[fd]->wrttime = (((now->tm_hour)&0x1f)<<11) |
984 (((now->tm_min)&0x3f)<<5) |
985 (((now->tm_sec/2)&0x1f));
986#endif
987}
959 988
960void dircache_mkdir(const char *path) 989void dircache_mkdir(const char *path)
961{ /* Test ok. */ 990{ /* Test ok. */
diff --git a/firmware/common/file.c b/firmware/common/file.c
index d526f28859..ea2471ae92 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -250,6 +250,7 @@ int close(int fd)
250 return rc * 10 - 3; 250 return rc * 10 - 3;
251#ifdef HAVE_DIRCACHE 251#ifdef HAVE_DIRCACHE
252 dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); 252 dircache_update_filesize(fd, file->size, file->fatfile.firstcluster);
253 dircache_update_filetime(fd);
253#endif 254#endif
254 } 255 }
255 256
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 6b47f3f1bb..7d2111697c 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -97,6 +97,7 @@ void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size)
97 97
98void dircache_bind(int fd, const char *path); 98void dircache_bind(int fd, const char *path);
99void dircache_update_filesize(int fd, long newsize, long startcluster); 99void dircache_update_filesize(int fd, long newsize, long startcluster);
100void dircache_update_filetime(int fd);
100void dircache_mkdir(const char *path); 101void dircache_mkdir(const char *path);
101void dircache_rmdir(const char *path); 102void dircache_rmdir(const char *path);
102void dircache_remove(const char *name); 103void dircache_remove(const char *name);