diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-02 13:24:51 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-02 13:24:51 +0000 |
commit | e73f287b5aa14a209627617cbab2f219be59b775 (patch) | |
tree | 24679fbd4808f071b6abaaf590e1c39d0604835f /firmware/common | |
parent | 74b16659879ba7090f17fcd3e537c90d9d9b8f2b (diff) |
Fix FS#7679 - modifying files with dircahce enabled doesnt change the access time/date in dircache
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14580 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dircache.c | 29 | ||||
-rw-r--r-- | firmware/common/file.c | 1 |
2 files changed, 30 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 @@ #include "usb.h" #include "file.h" #include "buffer.h" +#if CONFIG_RTC +#include "time.h" +#include "timefuncs.h" +#endif /* Queue commands. */ #define DIRCACHE_BUILD 1 @@ -956,6 +960,31 @@ void dircache_update_filesize(int fd, long newsize, long startcluster) fd_bindings[fd]->size = newsize; fd_bindings[fd]->startcluster = startcluster; } +void dircache_update_filetime(int fd) +{ +#if CONFIG_RTC == 0 + (void)fd; +#else + short year; + struct tm *now = get_time(); + if (!dircache_initialized || fd < 0) + return ; + + if (fd_bindings[fd] == NULL) + { + logf("dircache fd access error"); + dircache_initialized = false; + return ; + } + year = now->tm_year+1900-1980; + fd_bindings[fd]->wrtdate = (((year)&0x7f)<<9) | + (((now->tm_mon+1)&0xf)<<5) | + (((now->tm_mday)&0x1f)); + fd_bindings[fd]->wrttime = (((now->tm_hour)&0x1f)<<11) | + (((now->tm_min)&0x3f)<<5) | + (((now->tm_sec/2)&0x1f)); +#endif +} void dircache_mkdir(const char *path) { /* 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) return rc * 10 - 3; #ifdef HAVE_DIRCACHE dircache_update_filesize(fd, file->size, file->fatfile.firstcluster); + dircache_update_filetime(fd); #endif } |