summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-02 13:24:51 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-02 13:24:51 +0000
commite73f287b5aa14a209627617cbab2f219be59b775 (patch)
tree24679fbd4808f071b6abaaf590e1c39d0604835f
parent74b16659879ba7090f17fcd3e537c90d9d9b8f2b (diff)
downloadrockbox-e73f287b5aa14a209627617cbab2f219be59b775.zip
rockbox-e73f287b5aa14a209627617cbab2f219be59b775.tar.gz
rockbox-e73f287b5aa14a209627617cbab2f219be59b775.tar.bz2
rockbox-e73f287b5aa14a209627617cbab2f219be59b775.tar.xz
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
-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 97c5884..ab33d12 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 d526f28..ea2471a 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
}
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 6b47f3f..7d21116 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)
void dircache_bind(int fd, const char *path);
void dircache_update_filesize(int fd, long newsize, long startcluster);
+void dircache_update_filetime(int fd);
void dircache_mkdir(const char *path);
void dircache_rmdir(const char *path);
void dircache_remove(const char *name);