equal
deleted
inserted
replaced
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // f32\sfat\sl_file.cpp |
14 // f32\sfat32\sl_file.cpp |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 #include "sl_std.h" |
18 #include "sl_std.h" |
19 #include "sl_cache.h" |
19 #include "sl_cache.h" |
243 const TUint curSize = FCB_FileSize(); |
243 const TUint curSize = FCB_FileSize(); |
244 const TUint length = (TUint)aLength; |
244 const TUint length = (TUint)aLength; |
245 |
245 |
246 if((startPos + length > curSize) || (startPos > startPos + length) ) |
246 if((startPos + length > curSize) || (startPos > startPos + length) ) |
247 aLength=curSize-startPos; |
247 aLength=curSize-startPos; |
248 |
248 |
249 FatMount().ReadFromClusterListL(iCurrentPos,aLength,aDes,aMessage,aOffset); |
249 TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0; |
|
250 |
|
251 FatMount().ReadFromClusterListL(iCurrentPos,aLength,aDes,aMessage,aOffset, flag); |
250 aLength=iCurrentPos.iPos-startPos; |
252 aLength=iCurrentPos.iPos-startPos; |
251 } |
253 } |
252 |
254 |
253 |
255 |
254 void CFatFileCB::ReadL(TInt aFilePos,TInt& aLength,const TAny* aTrg,const RMessagePtr2& aMessage) |
256 void CFatFileCB::ReadL(TInt aFilePos,TInt& aLength,const TAny* aTrg,const RMessagePtr2& aMessage) |
293 |
295 |
294 TUint startPos=iCurrentPos.iPos; |
296 TUint startPos=iCurrentPos.iPos; |
295 TUint badcluster=0; |
297 TUint badcluster=0; |
296 TUint goodcluster=0; |
298 TUint goodcluster=0; |
297 |
299 |
298 TRAPD(ret, FatMount().WriteToClusterListL(iCurrentPos,aLength,aSrc,aMessage,aOffset,badcluster, goodcluster)); |
300 TUint flag = DirectIOMode(aMessage) ? RLocalDrive::ELocDrvDirectIO : 0; |
|
301 |
|
302 TRAPD(ret, FatMount().WriteToClusterListL(iCurrentPos,aLength,aSrc,aMessage,aOffset,badcluster, goodcluster, flag)); |
299 |
303 |
300 if (ret == KErrCorrupt || ret == KErrDied) |
304 if (ret == KErrCorrupt || ret == KErrDied) |
301 { |
305 { |
302 if(startCluster == 0) |
306 if(startCluster == 0) |
303 { //Empty File, revert all the clusters allocated. |
307 { //Empty File, revert all the clusters allocated. |
365 while(FAT().GetNextClusterL(aCluster)); |
369 while(FAT().GetNextClusterL(aCluster)); |
366 } |
370 } |
367 } |
371 } |
368 aLength=iCurrentPos.iPos-startPos; |
372 aLength=iCurrentPos.iPos-startPos; |
369 |
373 |
370 if(FatMount().IsRuggedFSys() && pos+(TUint)aLength > FCB_FileSize()) |
374 if(!IsSequentialMode() && FatMount().IsRuggedFSys() && pos+(TUint)aLength > FCB_FileSize()) |
371 { |
375 { |
372 WriteFileSizeL(pos+aLength); |
376 WriteFileSizeL(pos+aLength); |
373 } |
377 } |
374 |
378 |
375 } |
379 } |
377 |
381 |
378 void CFatFileCB::WriteL(TInt aFilePos,TInt& aLength,const TAny* aSrc,const RMessagePtr2& aMessage) |
382 void CFatFileCB::WriteL(TInt aFilePos,TInt& aLength,const TAny* aSrc,const RMessagePtr2& aMessage) |
379 { |
383 { |
380 WriteL(TInt64(aFilePos),aLength,(TDesC8*) aSrc,aMessage, 0); |
384 WriteL(TInt64(aFilePos),aLength,(TDesC8*) aSrc,aMessage, 0); |
381 } |
385 } |
382 |
|
383 |
386 |
384 |
387 |
385 //----------------------------------------------------------------------------- |
388 //----------------------------------------------------------------------------- |
386 |
389 |
387 void CFatFileCB::ResizeIndex(TInt aNewMult,TUint aNewSize) |
390 void CFatFileCB::ResizeIndex(TInt aNewMult,TUint aNewSize) |
500 |
503 |
501 //-- max. file size for FAT is 4GB-1 |
504 //-- max. file size for FAT is 4GB-1 |
502 if (I64HIGH(aSize)) |
505 if (I64HIGH(aSize)) |
503 User::Leave(KErrNotSupported); |
506 User::Leave(KErrNotSupported); |
504 |
507 |
505 DoSetSizeL(I64LOW(aSize), FatMount().IsRuggedFSys()); |
508 DoSetSizeL(I64LOW(aSize), FatMount().IsRuggedFSys()); |
506 } |
509 } |
507 |
510 |
508 |
511 |
509 void CFatFileCB::SetSizeL(TInt aSize) |
512 void CFatFileCB::SetSizeL(TInt aSize) |
510 { |
513 { |
518 void CFatFileCB::DoShrinkFileToZeroSizeL() |
521 void CFatFileCB::DoShrinkFileToZeroSizeL() |
519 { |
522 { |
520 ASSERT(FCB_FileSize()); |
523 ASSERT(FCB_FileSize()); |
521 ASSERT(FileSizeModified()); |
524 ASSERT(FileSizeModified()); |
522 |
525 |
523 ClearIndex(0); //-- clear seek index array |
526 ClearIndex(0); // Clear seek index array |
524 |
527 |
525 //-- update file dir. entry |
528 //-- update file dir. entry |
526 const TUint32 cluster = FCB_StartCluster(); |
529 const TUint32 cluster = FCB_StartCluster(); |
527 FCB_SetStartCluster(0); |
530 FCB_SetStartCluster(0); |
528 FCB_SetFileSize(0); |
531 FCB_SetFileSize(0); |
606 iCurrentPos=currentPos; |
609 iCurrentPos=currentPos; |
607 } |
610 } |
608 |
611 |
609 FAT().FlushL(); |
612 FAT().FlushL(); |
610 |
613 |
611 if(aForceCachesFlush) // write file size if increasing |
614 if(!IsSequentialMode() && aForceCachesFlush) // Write file size directly to its dir. entry if a cache flush |
612 WriteFileSizeL(aNewSize); |
615 WriteFileSizeL(aNewSize); // is needed and rugged FAT is not ignored by client |
613 } |
616 } |
614 |
617 |
615 } |
618 } |
616 |
619 |
617 //----------------------------------------------------------------------------- |
620 //----------------------------------------------------------------------------- |
882 else |
885 else |
883 return KErrNone; |
886 return KErrNone; |
884 } |
887 } |
885 |
888 |
886 |
889 |
887 |
|
888 TInt CFatFileCB::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput) |
890 TInt CFatFileCB::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput) |
889 { |
891 { |
890 switch(aInterfaceId) |
892 switch(aInterfaceId) |
891 { |
893 { |
892 case EExtendedFileInterface: |
894 case EExtendedFileInterface: |
904 return CFileCB::GetInterface(aInterfaceId,aInterface,aInput); |
906 return CFileCB::GetInterface(aInterfaceId,aInterface,aInput); |
905 } |
907 } |
906 } |
908 } |
907 |
909 |
908 |
910 |
909 |
|
910 |
|
911 /** |
911 /** |
912 Overwrites file's start cluster (iStartCluster) in its directory entry. |
912 Overwrites file's start cluster (iStartCluster) in its directory entry. |
913 */ |
913 */ |
914 void CFatFileCB::FlushStartClusterL() |
914 void CFatFileCB::FlushStartClusterL() |
915 { |
915 { |