summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2010-03-15 12:31:24 +0000
committerAmaury Pouly <pamaury@rockbox.org>2010-03-15 12:31:24 +0000
commit46565f594a9601734b51be16999ad4914798bfc6 (patch)
tree26251b18d5218aff976337869688306ebfdc3cef /firmware
parent97c1497b8d43f27206664ea377a86f6f94384b3b (diff)
downloadrockbox-46565f594a9601734b51be16999ad4914798bfc6.tar.gz
rockbox-46565f594a9601734b51be16999ad4914798bfc6.zip
fat: make fat_open more flexible by accepting the file==&dir->file and make fat_opendir also more flexible by accepting dir==parent_dir
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25202 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/fat.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 169672f08e..d0b697ef60 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -1632,6 +1632,15 @@ int fat_open(IF_MV2(int volume,)
1632 struct fat_file *file, 1632 struct fat_file *file,
1633 const struct fat_dir* dir) 1633 const struct fat_dir* dir)
1634{ 1634{
1635 /* Remember where the file's dir entry is located
1636 * Do it befoe assigning other fields so that fat_open
1637 * can be called with file == &dir->file (see fat_opendir) */
1638 if ( dir ) {
1639 file->direntry = dir->entry - 1;
1640 file->direntries = dir->entrycount;
1641 file->dircluster = dir->file.firstcluster;
1642 }
1643
1635 file->firstcluster = startcluster; 1644 file->firstcluster = startcluster;
1636 file->lastcluster = startcluster; 1645 file->lastcluster = startcluster;
1637 file->lastsector = 0; 1646 file->lastsector = 0;
@@ -1648,12 +1657,6 @@ int fat_open(IF_MV2(int volume,)
1648 } 1657 }
1649#endif 1658#endif
1650 1659
1651 /* remember where the file's dir entry is located */
1652 if ( dir ) {
1653 file->direntry = dir->entry - 1;
1654 file->direntries = dir->entrycount;
1655 file->dircluster = dir->file.firstcluster;
1656 }
1657 LDEBUGF("fat_open(%lx), entry %d\n",startcluster,file->direntry); 1660 LDEBUGF("fat_open(%lx), entry %d\n",startcluster,file->direntry);
1658 return 0; 1661 return 0;
1659} 1662}
@@ -2301,9 +2304,6 @@ int fat_opendir(IF_MV2(int volume,)
2301#endif 2304#endif
2302 int rc; 2305 int rc;
2303 2306
2304 dir->entry = 0;
2305 dir->sector = 0;
2306
2307 if (startcluster == 0) 2307 if (startcluster == 0)
2308 startcluster = fat_bpb->bpb_rootclus; 2308 startcluster = fat_bpb->bpb_rootclus;
2309 2309
@@ -2314,6 +2314,11 @@ int fat_opendir(IF_MV2(int volume,)
2314 " (error code %d)\n", rc); 2314 " (error code %d)\n", rc);
2315 return rc * 10 - 1; 2315 return rc * 10 - 1;
2316 } 2316 }
2317
2318 /* assign them after fat_open call so that fat_opendir can be called with the same
2319 * fat_dir as parent and result */
2320 dir->entry = 0;
2321 dir->sector = 0;
2317 2322
2318 return 0; 2323 return 0;
2319} 2324}