changeset 200 | 73ea206103e6 |
parent 90 | 947f0dc9f7a8 |
child 176 | af6ec97d9189 |
152:657f875b013e | 200:73ea206103e6 |
---|---|
1605 //----------------------------------------------------------------------------------------- |
1605 //----------------------------------------------------------------------------------------- |
1606 |
1606 |
1607 /** |
1607 /** |
1608 Overwrite as many contiguous file clusters as possible. |
1608 Overwrite as many contiguous file clusters as possible. |
1609 */ |
1609 */ |
1610 void CFatMountCB::DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint aLastcluster, TUint& aBadcluster, TUint& aGoodcluster) |
1610 void CFatMountCB::DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint aLastcluster, TUint& aBadcluster, TUint& aGoodcluster, TUint aFlag) |
1611 { |
1611 { |
1612 |
1612 |
1613 __PRINT(_L("CFatMountCB::DoWriteToClusterListL")); |
1613 __PRINT(_L("CFatMountCB::DoWriteToClusterListL")); |
1614 __ASSERT_ALWAYS(aPos.Cluster()>=KFatFirstSearchCluster,User::Leave(KErrCorrupt)); |
1614 __ASSERT_ALWAYS(aPos.Cluster()>=KFatFirstSearchCluster,User::Leave(KErrCorrupt)); |
1615 |
1615 |
1619 const TInt maxClusters=((aLength+clusterRelativePos-1)>>ClusterSizeLog2())+1; |
1619 const TInt maxClusters=((aLength+clusterRelativePos-1)>>ClusterSizeLog2())+1; |
1620 const TInt clusterListLen=FAT().CountContiguousClustersL(aPos.iCluster,endCluster,maxClusters); |
1620 const TInt clusterListLen=FAT().CountContiguousClustersL(aPos.iCluster,endCluster,maxClusters); |
1621 const TInt writeLength=Min(aLength,(clusterListLen<<ClusterSizeLog2())-clusterRelativePos); |
1621 const TInt writeLength=Min(aLength,(clusterListLen<<ClusterSizeLog2())-clusterRelativePos); |
1622 TInt64 dataStart=FAT().DataPositionInBytes(aPos.iCluster)+clusterRelativePos; |
1622 TInt64 dataStart=FAT().DataPositionInBytes(aPos.iCluster)+clusterRelativePos; |
1623 |
1623 |
1624 TRAPD(r, iRawDisk->WriteL(dataStart,writeLength,aSrc,aMessage,anOffset)); |
1624 TRAPD(r, iRawDisk->WriteL(dataStart,writeLength,aSrc,aMessage,anOffset, aFlag)); |
1625 |
1625 |
1626 if(r == KErrNone) // Write succeded |
1626 if(r == KErrNone) // Write succeded |
1627 { |
1627 { |
1628 aPos.iPos+=writeLength; |
1628 aPos.iPos+=writeLength; |
1629 aPos.iCluster=endCluster; |
1629 aPos.iCluster=endCluster; |
1734 User::Leave(KErrCorrupt); |
1734 User::Leave(KErrCorrupt); |
1735 } |
1735 } |
1736 |
1736 |
1737 //----------------------------------------------------------------------------------------- |
1737 //----------------------------------------------------------------------------------------- |
1738 |
1738 |
1739 void CFatMountCB::WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint& aBadcluster, TUint& aGoodcluster) |
1739 void CFatMountCB::WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint& aBadcluster, TUint& aGoodcluster, TUint aFlag) |
1740 // |
1740 // |
1741 // Overwrite cluster list. |
1741 // Overwrite cluster list. |
1742 // |
1742 // |
1743 { |
1743 { |
1744 |
1744 |
1756 |
1756 |
1757 TUint offset=0; |
1757 TUint offset=0; |
1758 TInt previouscluster=0; |
1758 TInt previouscluster=0; |
1759 FOREVER |
1759 FOREVER |
1760 { |
1760 { |
1761 DoWriteToClusterListL(aPos,length-offset,aSrc,aMessage,anOffset+offset, previouscluster, aBadcluster, aGoodcluster); |
1761 DoWriteToClusterListL(aPos,length-offset,aSrc,aMessage,anOffset+offset, previouscluster, aBadcluster, aGoodcluster, aFlag); |
1762 if (offset == (aPos.iPos-startPos)) |
1762 if (offset == (aPos.iPos-startPos)) |
1763 continue; |
1763 continue; |
1764 offset=aPos.iPos-startPos; |
1764 offset=aPos.iPos-startPos; |
1765 __ASSERT_ALWAYS(aPos.iPos>startPos,User::Leave(KErrCorrupt)); |
1765 __ASSERT_ALWAYS(aPos.iPos>startPos,User::Leave(KErrCorrupt)); |
1766 previouscluster=aPos.iCluster; |
1766 previouscluster=aPos.iCluster; |
1771 } |
1771 } |
1772 } |
1772 } |
1773 |
1773 |
1774 //----------------------------------------------------------------------------------------- |
1774 //----------------------------------------------------------------------------------------- |
1775 |
1775 |
1776 void CFatMountCB::DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const |
1776 void CFatMountCB::DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset, TUint aFlag) const |
1777 // |
1777 // |
1778 // Read from as many contiguous file clusters as possible |
1778 // Read from as many contiguous file clusters as possible |
1779 // |
1779 // |
1780 { |
1780 { |
1781 |
1781 |
1787 const TInt maxClusters=((aLength+clusterRelativePos-1)>>ClusterSizeLog2())+1; |
1787 const TInt maxClusters=((aLength+clusterRelativePos-1)>>ClusterSizeLog2())+1; |
1788 const TInt clusterListLen=FAT().CountContiguousClustersL(aPos.iCluster,endCluster,maxClusters); |
1788 const TInt clusterListLen=FAT().CountContiguousClustersL(aPos.iCluster,endCluster,maxClusters); |
1789 const TInt readLength=Min(aLength,(clusterListLen<<ClusterSizeLog2())-clusterRelativePos); |
1789 const TInt readLength=Min(aLength,(clusterListLen<<ClusterSizeLog2())-clusterRelativePos); |
1790 const TInt64 dataStart=FAT().DataPositionInBytes(aPos.iCluster)+clusterRelativePos; |
1790 const TInt64 dataStart=FAT().DataPositionInBytes(aPos.iCluster)+clusterRelativePos; |
1791 |
1791 |
1792 TRAPD(r, iRawDisk->ReadL(dataStart,readLength,aTrg,aMessage,anOffset)); |
1792 TRAPD(r, iRawDisk->ReadL(dataStart,readLength,aTrg,aMessage,anOffset, aFlag)); |
1793 |
1793 |
1794 if(r == KErrNone) // Read succeded |
1794 if(r == KErrNone) // Read succeded |
1795 { |
1795 { |
1796 aPos.iPos+=readLength; |
1796 aPos.iPos+=readLength; |
1797 aPos.iCluster=endCluster; |
1797 aPos.iCluster=endCluster; |
1812 User::Leave(KErrCorrupt); |
1812 User::Leave(KErrCorrupt); |
1813 } |
1813 } |
1814 |
1814 |
1815 //----------------------------------------------------------------------------------------- |
1815 //----------------------------------------------------------------------------------------- |
1816 |
1816 |
1817 void CFatMountCB::ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const |
1817 void CFatMountCB::ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset, TUint aFlag) const |
1818 // |
1818 // |
1819 // Read from cluster list |
1819 // Read from cluster list |
1820 // |
1820 // |
1821 { |
1821 { |
1822 |
1822 |
1832 } |
1832 } |
1833 |
1833 |
1834 TInt offset=0; |
1834 TInt offset=0; |
1835 FOREVER |
1835 FOREVER |
1836 { |
1836 { |
1837 DoReadFromClusterListL(aPos,aLength-offset,aTrg,aMessage,anOffset+offset); |
1837 DoReadFromClusterListL(aPos,aLength-offset,aTrg,aMessage,anOffset+offset, aFlag); |
1838 offset=aPos.iPos-startPos; |
1838 offset=aPos.iPos-startPos; |
1839 if ((offset<aLength)) |
1839 if ((offset<aLength)) |
1840 { |
1840 { |
1841 __ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt)); |
1841 __ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt)); |
1842 } |
1842 } |
3226 { |
3226 { |
3227 // Read the remaining length or the entire cluster block whichever is smaller |
3227 // Read the remaining length or the entire cluster block whichever is smaller |
3228 TInt readLength = Min(aLength-readTotal,(clusterListLen<<ClusterSizeLog2())-pos); |
3228 TInt readLength = Min(aLength-readTotal,(clusterListLen<<ClusterSizeLog2())-pos); |
3229 __ASSERT_DEBUG(readLength>0,Fault(EReadFileSectionFailed)); |
3229 __ASSERT_DEBUG(readLength>0,Fault(EReadFileSectionFailed)); |
3230 TInt64 dataAddress=(FAT().DataPositionInBytes(cluster))+pos; |
3230 TInt64 dataAddress=(FAT().DataPositionInBytes(cluster))+pos; |
3231 iRawDisk->ReadL(dataAddress,readLength,aTrg,aMessage,readTotal); |
3231 iRawDisk->ReadL(dataAddress,readLength,aTrg,aMessage,readTotal, 0); |
3232 readTotal += readLength; |
3232 readTotal += readLength; |
3233 |
3233 |
3234 if (readTotal == aLength) |
3234 if (readTotal == aLength) |
3235 return; |
3235 return; |
3236 |
3236 |
3254 void CFatMountCB::RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const |
3254 void CFatMountCB::RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const |
3255 // |
3255 // |
3256 // Read aLength of data from disk directly to thread relative descriptor |
3256 // Read aLength of data from disk directly to thread relative descriptor |
3257 // |
3257 // |
3258 { |
3258 { |
3259 iRawDisk->ReadL(aPos,aLength,aTrg,aMessage,anOffset); |
3259 iRawDisk->ReadL(aPos,aLength,aTrg,aMessage,anOffset, 0); |
3260 } |
3260 } |
3261 |
3261 |
3262 //----------------------------------------------------------------------------------------- |
3262 //----------------------------------------------------------------------------------------- |
3263 |
3263 |
3264 void CFatMountCB::RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage) |
3264 void CFatMountCB::RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage) |
3269 CheckWritableL(); |
3269 CheckWritableL(); |
3270 |
3270 |
3271 //-- check if we are trying to write to the FAT directly and wait until FAT scan thread finishes in this case. |
3271 //-- check if we are trying to write to the FAT directly and wait until FAT scan thread finishes in this case. |
3272 FAT().RequestRawWriteAccess(aPos, aLength); |
3272 FAT().RequestRawWriteAccess(aPos, aLength); |
3273 |
3273 |
3274 iRawDisk->WriteL(aPos,aLength,aSrc,aMessage,anOffset); |
3274 iRawDisk->WriteL(aPos,aLength,aSrc,aMessage,anOffset, 0); |
3275 //-- Note: FAT directory cache will be invalidated in MountL() |
3275 //-- Note: FAT directory cache will be invalidated in MountL() |
3276 } |
3276 } |
3277 |
3277 |
3278 //----------------------------------------------------------------------------------------- |
3278 //----------------------------------------------------------------------------------------- |
3279 /** |
3279 /** |