forked from len0rd/rockbox
Added fat_seek()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@271 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9a3c16dea8
commit
0ea9f3772a
2 changed files with 31 additions and 0 deletions
|
|
@ -860,6 +860,34 @@ int fat_read(struct bpb *bpb,
|
|||
return sectorcount;
|
||||
}
|
||||
|
||||
int fat_seek(struct bpb *bpb,
|
||||
struct fat_fileent *ent,
|
||||
int seeksector )
|
||||
{
|
||||
int cluster = ent->firstcluster;
|
||||
int sector;
|
||||
int numsec = 0;
|
||||
int i;
|
||||
|
||||
for (i=0; i<seeksector; i++) {
|
||||
numsec++;
|
||||
if ( numsec >= bpb->bpb_secperclus ) {
|
||||
cluster = get_next_cluster(bpb,cluster);
|
||||
if (!cluster)
|
||||
/* end of file */
|
||||
return -1;
|
||||
|
||||
sector = cluster2sec(bpb,cluster);
|
||||
if (sector<0)
|
||||
return -2;
|
||||
numsec=0;
|
||||
}
|
||||
}
|
||||
ent->nextcluster = cluster;
|
||||
ent->nextsector = sector;
|
||||
ent->sectornum = numsec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fat_opendir(struct bpb *bpb,
|
||||
struct fat_dirent *ent,
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ extern int fat_read(struct bpb *bpb,
|
|||
struct fat_fileent *ent,
|
||||
int sectorcount,
|
||||
void* buf );
|
||||
extern int fat_seek(struct bpb *bpb,
|
||||
struct fat_fileent *ent,
|
||||
int sector );
|
||||
|
||||
extern int fat_opendir(struct bpb *bpb,
|
||||
struct fat_dirent *ent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue