I64 ClusNumNext(CDrv *dv,I64 c,I64 cnt=1) {//Return next cnt'th clus in chain. Bool unlock; DrvChk(dv); if (cnt<=0) return c; try { unlock=DrvLock(dv); switch (dv->fs_type) { case FSt_REDSEA: c+=cnt; break; case FSt_FAT32: while (cnt-->0 && 0cur_fat_blk[c & (BLK_SIZE/4-1)]; } if (!(0fs_type) { case FSt_REDSEA: return c; case FSt_FAT32: return dv->data_area+c*dv->spc; default: throw('Drv'); } } I64 ClusBlkRead(CDrv *dv,U8 *buf,I64 c,I64 blks) {//Accepts blk count, so padding on last clus is not read. I64 i; Bool unlock; DrvChk(dv); if (blks<=0) return c; try { unlock=DrvLock(dv); switch (dv->fs_type) { case FSt_REDSEA: BlkRead(dv,buf,c,blks); c+=blks; break; case FSt_FAT32: while (blks && 0dv->spc) i=dv->spc; BlkRead(dv,buf,dv->data_area+c*dv->spc,i); buf+=i<spc); } I64 ClusBlkWrite(CDrv *dv,U8 *buf,I64 c,I64 blks) {//Accepts blk count, so padding on last clus is not written. I64 i; Bool unlock; DrvChk(dv); if (blks<=0) return c; try { unlock=DrvLock(dv); switch (dv->fs_type) { case FSt_REDSEA: BlkWrite(dv,buf,c,blks); c=0; break; case FSt_FAT32: while (blks) { if (!(0dv->spc) i=dv->spc; BlkWrite(dv,buf,dv->data_area+c*dv->spc,i); buf+=i<spc); } I64 ClusAlloc(CDrv *dv,I64 c=0,I64 cnt=1,Bool contiguous=FALSE) {//Alloc clus cnt into chain. //c=0 means first clus in chain DrvChk(dv); if (cnt<=0) return c; switch (dv->fs_type) { case FSt_REDSEA: return RedSeaAllocClus(dv,cnt); case FSt_FAT32: if (contiguous) { if (c) throw('File'); return FAT32AllocContiguousClus(dv,cnt); } else return FAT32AllocClus(dv,c,cnt); default: throw('Drv'); } }