forked from len0rd/rockbox
Better dircache handling in simulator
Actually add files to the dircache (as well as removing them) and remove them only when they were found on disk. This matches the native behavior and prevents the dircache from becoming uninitialized when a previously created or nonexisting file is being removed. This typically would happen during a database update. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29715 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
80889ee828
commit
d49d2e1675
1 changed files with 16 additions and 3 deletions
|
@ -147,6 +147,7 @@ extern int _wrmdir(const wchar_t*);
|
|||
|
||||
|
||||
#ifdef HAVE_DIRCACHE
|
||||
void dircache_add_file(const char *name, long startcluster);
|
||||
void dircache_remove(const char *name);
|
||||
void dircache_rename(const char *oldname, const char *newname);
|
||||
#endif
|
||||
|
@ -389,6 +390,10 @@ int sim_open(const char *name, int o, ...)
|
|||
va_start(ap, o);
|
||||
mode_t mode = va_arg(ap, unsigned int);
|
||||
ret = OPEN(get_sim_pathname(name), opts, mode);
|
||||
#ifdef HAVE_DIRCACHE
|
||||
if (ret >= 0)
|
||||
dircache_add_file(name, 0);
|
||||
#endif
|
||||
va_end(ap);
|
||||
}
|
||||
else
|
||||
|
@ -410,7 +415,13 @@ int sim_close(int fd)
|
|||
|
||||
int sim_creat(const char *name, mode_t mode)
|
||||
{
|
||||
return OPEN(get_sim_pathname(name), O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||
int ret = OPEN(get_sim_pathname(name),
|
||||
O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||
#ifdef HAVE_DIRCACHE
|
||||
if (ret >= 0)
|
||||
dircache_add_file(name, 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t sim_read(int fd, void *buf, size_t count)
|
||||
|
@ -460,10 +471,12 @@ int sim_rmdir(const char *name)
|
|||
|
||||
int sim_remove(const char *name)
|
||||
{
|
||||
int ret = REMOVE(get_sim_pathname(name));
|
||||
#ifdef HAVE_DIRCACHE
|
||||
if (ret >= 0)
|
||||
dircache_remove(name);
|
||||
#endif
|
||||
return REMOVE(get_sim_pathname(name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sim_rename(const char *oldname, const char *newname)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue