diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-05-08 12:02:42 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-05-08 12:02:42 +0000 |
commit | 7dd442b7c36f43e3593905d86283f707b0b2dfe1 (patch) | |
tree | 05674032c27108fd337833eead773b36562a9eaa | |
parent | 143471447c3f7307c5fc24a861bdb73df34d4a7c (diff) |
Fixed EOF handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@512 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/fat.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 7951b6b280..3a3f63d9f1 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -795,6 +795,9 @@ int fat_read( struct fat_file *file, int sectorcount, void* buf ) int numsec = file->sectornum; int err, i; + if ( sector == -1 ) + return 0; + for ( i=0; i<sectorcount; i++ ) { err = ata_read_sectors(sector + fat_bpb.startsector, 1, (char*)buf+(i*SECTOR_SIZE)); @@ -807,8 +810,11 @@ int fat_read( struct fat_file *file, int sectorcount, void* buf ) numsec++; if ( numsec >= fat_bpb.bpb_secperclus ) { cluster = get_next_cluster(cluster); - if (!cluster) - break; /* end of file */ + if (!cluster) { + /* end of file */ + sector = -1; + break; + } sector = cluster2sec(cluster); if (sector<0) |