userlibandfileserver/fileserver/sfat32/sl_file.cpp
branchRCL_3
changeset 294 039a3e647356
parent 257 3e88ff8f41d5
--- a/userlibandfileserver/fileserver/sfat32/sl_file.cpp	Wed Sep 15 13:42:27 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/sl_file.cpp	Wed Oct 13 16:04:24 2010 +0300
@@ -103,6 +103,18 @@
 	iSeekIndex[seekPos] = aStoredCluster;
 	}
 
+TBool CFatFileCB::IsSeekBackwards(TUint aPos)
+//
+// Return true if aPos<currentPos
+//
+	{
+	
+	TUint cluster=iCurrentPos.iCluster<<ClusterSizeLog2();
+	TInt offset=ClusterRelativePos(iCurrentPos.iPos);
+	TUint currentPos=cluster+offset;
+	return(aPos<currentPos);
+	}
+
 void CFatFileCB::CheckPosL(TUint aPos)
 //
 // Check that the file is positioned correctly.
@@ -114,6 +126,9 @@
 		return;
     __ASSERT_DEBUG(aPos <= FCB_FileSize(), Fault(EFatFilePosBeyondEnd));
 
+	if (FileSizeModified() && IsSeekBackwards(aPos))
+		FlushDataL(); 
+	
 	TUint newRelCluster=aPos>>ClusterSizeLog2();
 	if ( aPos && (aPos==(newRelCluster<<ClusterSizeLog2())) )
 		newRelCluster--;
@@ -230,10 +245,8 @@
 	
 	if((startPos + length > curSize) || (startPos > startPos + length) )
 		aLength=curSize-startPos;
-		
-	TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0;
 	
-    FatMount().ReadFromClusterListL(iCurrentPos,aLength,aDes,aMessage,aOffset, flag);
+    FatMount().ReadFromClusterListL(iCurrentPos,aLength,aDes,aMessage,aOffset);
 	aLength=iCurrentPos.iPos-startPos;
 	}
 
@@ -282,9 +295,7 @@
 	TUint badcluster=0;
 	TUint goodcluster=0;
    	
-	TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0;
-	
-	TRAPD(ret, FatMount().WriteToClusterListL(iCurrentPos,aLength,aSrc,aMessage,aOffset,badcluster, goodcluster, flag));
+	TRAPD(ret, FatMount().WriteToClusterListL(iCurrentPos,aLength,aSrc,aMessage,aOffset,badcluster, goodcluster));
    	
 	if (ret == KErrCorrupt || ret == KErrDied)
 		{
@@ -853,15 +864,10 @@
 	else
 		return KErrNotSupported;
 
-    TInt r;
-	
-    // Fetch the address of cluster 0
-	TRAP(r, aInfo.iStartBlockAddress = fatMount.FAT().DataPositionInBytesL(KFirstClusterNum));
-	if (r != KErrNone)
-		return r;
+	// Fetch the address of cluster 0
+	aInfo.iStartBlockAddress = fatMount.FAT().DataPositionInBytes(KFirstClusterNum);
 
-
-	TRAP(r, CheckPosL(startPos));
+	TRAPD(r, CheckPosL(startPos));
 	if (r != KErrNone)
 		return r;