diff options
Diffstat (limited to 'firmware/common/dircache.c')
-rw-r--r-- | firmware/common/dircache.c | 29 |
1 files changed, 29 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 | } |
963 | void 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 | ||
960 | void dircache_mkdir(const char *path) | 989 | void dircache_mkdir(const char *path) |
961 | { /* Test ok. */ | 990 | { /* Test ok. */ |