262 } |
262 } |
263 |
263 |
264 //----------------------------------------------------------------------------- |
264 //----------------------------------------------------------------------------- |
265 |
265 |
266 /** |
266 /** |
267 Count the number of contiguous cluster from a start cluster |
267 Count the number of continuous cluster from a start cluster in FAT table. |
268 |
268 |
269 @param aStartCluster cluster to start counting from |
269 @param aStartCluster cluster to start counting from |
270 @param anEndCluster contains the end cluster number upon return |
270 @param aEndCluster contains the end cluster number upon return |
271 @param aMaxCount Maximum cluster required |
271 @param aMaxCount Maximum cluster required |
272 @leave System wide error values |
272 @return Number of continuous clusters from aStartCluster. |
273 @return Number of contiguous clusters from aStartCluster. |
273 */ |
274 */ |
274 TUint32 CFatTable::CountContiguousClustersL(TUint32 aStartCluster, TUint32& aEndCluster, TUint32 aMaxCount) const |
275 TInt CFatTable::CountContiguousClustersL(TUint32 aStartCluster,TInt& anEndCluster,TUint32 aMaxCount) const |
|
276 { |
275 { |
277 __PRINT2(_L("CFatTable::CountContiguousClustersL() start:%d, max:%d"),aStartCluster, aMaxCount); |
276 __PRINT2(_L("CFatTable::CountContiguousClustersL() start:%d, max:%d"),aStartCluster, aMaxCount); |
278 TUint32 clusterListLen=1; |
277 |
279 TInt endCluster=aStartCluster; |
278 ASSERT(ClusterNumberValid(aStartCluster)); |
280 TInt64 endClusterPos=DataPositionInBytes(endCluster); |
279 |
281 while (clusterListLen<aMaxCount) |
280 TUint32 currClusterNo = aStartCluster; |
282 { |
281 |
283 TInt oldCluster=endCluster; |
282 TUint32 clusterListLen; |
284 TInt64 oldClusterPos=endClusterPos; |
283 for(clusterListLen=1; clusterListLen < aMaxCount; ++clusterListLen) |
285 if (GetNextClusterL(endCluster)==EFalse || (endClusterPos=DataPositionInBytes(endCluster))!=(oldClusterPos+(1<<iOwner->ClusterSizeLog2()))) |
284 { |
286 { |
285 TUint32 nextClusterNo = currClusterNo; |
287 endCluster=oldCluster; |
286 |
288 break; |
287 if(!GetNextClusterL(nextClusterNo)) |
289 } |
288 break; //-- end of cluster chain |
290 clusterListLen++; |
289 |
291 } |
290 if(nextClusterNo != currClusterNo+1) |
292 anEndCluster=endCluster; |
291 break; //-- not the next cluster |
293 return(clusterListLen); |
292 |
|
293 currClusterNo = nextClusterNo; |
|
294 } |
|
295 |
|
296 aEndCluster = aStartCluster+clusterListLen-1; |
|
297 |
|
298 return clusterListLen; |
294 } |
299 } |
295 |
|
296 //----------------------------------------------------------------------------- |
300 //----------------------------------------------------------------------------- |
297 |
301 |
298 /** |
302 /** |
299 Extend a file or directory cluster chain, leaves if there are no free clusters (the disk is full). |
303 Extend a file or directory cluster chain, leaves if there are no free clusters (the disk is full). |
300 |
304 |
301 @param aNumber amount of clusters to allocate |
305 @param aNumber amount of clusters to allocate |
302 @param aCluster FAT entry index to start with. |
306 @param aCluster FAT entry index to start with. |
303 |
307 |
304 @leave KErrDiskFull + system wide error codes |
308 @leave KErrDiskFull + system wide error codes |
305 */ |
309 */ |
306 void CFatTable::ExtendClusterListL(TUint32 aNumber,TInt& aCluster) |
310 void CFatTable::ExtendClusterListL(TUint32 aNumber, TUint32& aCluster) |
307 { |
311 { |
308 __PRINT2(_L("CFatTable::ExtendClusterListL() num:%d, clust:%d"), aNumber, aCluster); |
312 __PRINT2(_L("CFatTable::ExtendClusterListL() num:%d, clust:%d"), aNumber, aCluster); |
309 __ASSERT_DEBUG(aNumber>0,Fault(EFatBadParameter)); |
313 __ASSERT_DEBUG(aNumber>0,Fault(EFatBadParameter)); |
310 |
314 |
311 while(aNumber && GetNextClusterL(aCluster)) |
315 while(aNumber && GetNextClusterL(aCluster)) |
1738 Get the next cluster in the chain from the FAT |
1742 Get the next cluster in the chain from the FAT |
1739 |
1743 |
1740 @param aCluster number to read, contains next cluster upon return |
1744 @param aCluster number to read, contains next cluster upon return |
1741 @return False if end of cluster chain |
1745 @return False if end of cluster chain |
1742 */ |
1746 */ |
1743 TBool CFatTable::GetNextClusterL(TInt& aCluster) const |
1747 TBool CFatTable::GetNextClusterL(TUint32& aCluster) const |
1744 { |
1748 { |
1745 __PRINT1(_L("CAtaFatTable::GetNextClusterL(%d)"), aCluster); |
1749 __PRINT1(_L("CAtaFatTable::GetNextClusterL(%d)"), aCluster); |
1746 |
1750 |
1747 const TUint32 nextCluster = ReadL(aCluster); |
1751 const TUint32 nextCluster = ReadL(aCluster); |
1748 const TBool bEOC = IsEndOfClusterCh(nextCluster); |
1752 const TBool bEOC = IsEndOfClusterCh(nextCluster); |