Fixed EOF handling

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@512 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-05-08 12:02:42 +00:00
parent 143471447c
commit 7dd442b7c3

View file

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