diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-18 19:28:22 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-11-18 19:28:22 +0000 |
commit | 10f2f89d0fd491df9294867eb5689c65d002ce15 (patch) | |
tree | 3c57f90786db48d860ab47b42dd20ea9a1677ccd | |
parent | 32a43e2ee688bf8b3c930685400a52910c512a1e (diff) | |
download | rockbox-10f2f89d0fd491df9294867eb5689c65d002ce15.tar.gz rockbox-10f2f89d0fd491df9294867eb5689c65d002ce15.zip |
Fixed an empty directory problem with dircache when renaming files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7966 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/common/dircache.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 259c34cdf5..0d93a42a61 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -708,6 +708,7 @@ void dircache_remove(const char *name) | |||
708 | void dircache_rename(const char *oldpath, const char *newpath) | 708 | void dircache_rename(const char *oldpath, const char *newpath) |
709 | { /* Test ok. */ | 709 | { /* Test ok. */ |
710 | struct dircache_entry *entry, *newentry; | 710 | struct dircache_entry *entry, *newentry; |
711 | struct dircache_entry oldentry; | ||
711 | 712 | ||
712 | if (!dircache_initialized) | 713 | if (!dircache_initialized) |
713 | return ; | 714 | return ; |
@@ -724,6 +725,10 @@ void dircache_rename(const char *oldpath, const char *newpath) | |||
724 | /* Delete the old entry. */ | 725 | /* Delete the old entry. */ |
725 | entry->name_len = 0; | 726 | entry->name_len = 0; |
726 | 727 | ||
728 | /** If we rename the same filename twice in a row, we need to | ||
729 | * save the data, because the entry will be re-used. */ | ||
730 | oldentry = *entry; | ||
731 | |||
727 | newentry = dircache_new_entry(newpath, entry->attribute); | 732 | newentry = dircache_new_entry(newpath, entry->attribute); |
728 | if (newentry == NULL) | 733 | if (newentry == NULL) |
729 | { | 734 | { |
@@ -731,13 +736,12 @@ void dircache_rename(const char *oldpath, const char *newpath) | |||
731 | return ; | 736 | return ; |
732 | } | 737 | } |
733 | 738 | ||
734 | //newentry->down = entry->down; | 739 | newentry->down = oldentry.down; |
735 | //entry->down = 0; | 740 | newentry->up = oldentry.up; |
736 | 741 | newentry->size = oldentry.size; | |
737 | newentry->size = entry->size; | 742 | newentry->startcluster = oldentry.startcluster; |
738 | newentry->startcluster = entry->startcluster; | 743 | newentry->wrttime = oldentry.wrttime; |
739 | newentry->wrttime = entry->wrttime; | 744 | newentry->wrtdate = oldentry.wrtdate; |
740 | newentry->wrtdate = entry->wrtdate; | ||
741 | } | 745 | } |
742 | 746 | ||
743 | void dircache_add_file(const char *path) | 747 | void dircache_add_file(const char *path) |