1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2007-09-02 13:24:51 +00:00
parent 74b1665987
commit e73f287b5a
3 changed files with 31 additions and 0 deletions

View file

@ -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. */

View file

@ -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
}

View file

@ -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);