equal
deleted
inserted
replaced
285 return(p); |
285 return(p); |
286 } |
286 } |
287 |
287 |
288 /** |
288 /** |
289 Copy memory with filling the source buffer with zeroes. Target and source buffers can overlap. |
289 Copy memory with filling the source buffer with zeroes. Target and source buffers can overlap. |
290 Used on RAMDrive srinking in order to wipe data from the file that is being deleted. |
290 Used on RAMDrive shrinking in order to wipe data from the file that is being deleted. |
291 |
291 |
292 @param aTrg pointer to the target address |
292 @param aTrg pointer to the target address |
293 @param aSrc pointer to the destination address |
293 @param aSrc pointer to the destination address |
294 @param aLength how many bytes to copy |
294 @param aLength how many bytes to copy |
295 @return A pointer to a location aLength bytes beyond aTrg (i.e. the location aTrg+aLength). |
295 @return A pointer to a location aLength bytes beyond aTrg (i.e. the location aTrg+aLength). |
389 TInt firstCluster = aNearestCluster = AllocateSingleClusterL(aNearestCluster); |
389 TInt firstCluster = aNearestCluster = AllocateSingleClusterL(aNearestCluster); |
390 |
390 |
391 |
391 |
392 if (aNumber>1) |
392 if (aNumber>1) |
393 {//-- if this part leaves (e.g. fail to expand the RAM drive), we will need to handle the first allocated EOC |
393 {//-- if this part leaves (e.g. fail to expand the RAM drive), we will need to handle the first allocated EOC |
394 TRAPD(nRes, ExtendClusterListL(aNumber-1, (TInt&)aNearestCluster)); |
394 TRAPD(nRes, ExtendClusterListL(aNumber-1, aNearestCluster)); |
395 if(nRes != KErrNone) |
395 if(nRes != KErrNone) |
396 { |
396 { |
397 __PRINT1(_L("CRamFatTable::AllocateClusterListL:ExtendClusterListL() failed with %d") ,nRes); |
397 __PRINT1(_L("CRamFatTable::AllocateClusterListL:ExtendClusterListL() failed with %d") ,nRes); |
398 FreeClusterListL(firstCluster); //-- clean up EOC in firstCluster |
398 FreeClusterListL(firstCluster); //-- clean up EOC in firstCluster |
399 User::Leave(nRes); |
399 User::Leave(nRes); |
429 |
429 |
430 @param aNumber number of clusters to allocate |
430 @param aNumber number of clusters to allocate |
431 @param aCluster starting cluster number / ending cluster number after |
431 @param aCluster starting cluster number / ending cluster number after |
432 @leave KErrDiskFull + system wide error codes |
432 @leave KErrDiskFull + system wide error codes |
433 */ |
433 */ |
434 void CRamFatTable::ExtendClusterListL(TUint32 aNumber, TInt& aCluster) |
434 void CRamFatTable::ExtendClusterListL(TUint32 aNumber, TUint32& aCluster) |
435 { |
435 { |
436 __PRINT2(_L("CRamFatTable::ExtendClusterListL(%d, %d)"), aNumber, aCluster); |
436 __PRINT2(_L("CRamFatTable::ExtendClusterListL(%d, %d)"), aNumber, aCluster); |
437 __ASSERT_DEBUG(aNumber>0,Fault(EFatBadParameter)); |
437 __ASSERT_DEBUG(aNumber>0,Fault(EFatBadParameter)); |
438 |
438 |
439 iOwner->EnlargeL(aNumber<<iOwner->ClusterSizeLog2()); |
439 iOwner->EnlargeL(aNumber<<iOwner->ClusterSizeLog2()); |
477 __PRINT1(_L("CRamFatTable::FreeClusterListL aCluster=%d"),aCluster); |
477 __PRINT1(_L("CRamFatTable::FreeClusterListL aCluster=%d"),aCluster); |
478 if (aCluster==0) |
478 if (aCluster==0) |
479 return; // File has no cluster allocated |
479 return; // File has no cluster allocated |
480 |
480 |
481 const TInt clusterShift=iOwner->ClusterSizeLog2(); |
481 const TInt clusterShift=iOwner->ClusterSizeLog2(); |
482 TInt startCluster=aCluster; |
482 TUint32 startCluster=aCluster; |
483 TInt endCluster=0; |
483 TUint32 endCluster=0; |
484 TInt totalFreed=0; |
484 TInt totalFreed=0; |
485 TLinAddr srcEnd=0; |
485 TLinAddr srcEnd=0; |
486 |
486 |
487 if(IsFat32()) |
487 if(IsFat32()) |
488 { |
488 { |
626 *entry=TUint16(cluster-aClusterShift); |
626 *entry=TUint16(cluster-aClusterShift); |
627 } |
627 } |
628 #endif |
628 #endif |
629 } |
629 } |
630 |
630 |
631 |
631 TUint32 CRamFatTable::CountContiguousClustersL(TUint32 aStartCluster, TUint32& aEndCluster, TUint32 aMaxCount) const |
632 |
632 { |
|
633 __PRINT2(_L("CRamFatTable::CountContiguousClustersL() start:%d, max:%d"),aStartCluster, aMaxCount); |
|
634 TUint32 clusterListLen=1; |
|
635 TUint32 endCluster=aStartCluster; |
|
636 TInt64 endClusterPos=DataPositionInBytes(endCluster); |
|
637 while (clusterListLen<aMaxCount) |
|
638 { |
|
639 TInt oldCluster=endCluster; |
|
640 TInt64 oldClusterPos=endClusterPos; |
|
641 if (GetNextClusterL(endCluster)==EFalse || (endClusterPos=DataPositionInBytes(endCluster))!=(oldClusterPos+(1<<iOwner->ClusterSizeLog2()))) |
|
642 { |
|
643 endCluster=oldCluster; |
|
644 break; |
|
645 } |
|
646 clusterListLen++; |
|
647 } |
|
648 aEndCluster=endCluster; |
|
649 |
|
650 return(clusterListLen); |
|
651 } |
|
652 |
|
653 |
|
654 |