userlibandfileserver/fileserver/sfat32/sl_file.cpp
changeset 109 b3a1d9898418
parent 90 947f0dc9f7a8
child 200 73ea206103e6
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
     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"
   365 			while(FAT().GetNextClusterL(aCluster));
   365 			while(FAT().GetNextClusterL(aCluster));
   366 			}
   366 			}
   367 		}
   367 		}
   368 	aLength=iCurrentPos.iPos-startPos;
   368 	aLength=iCurrentPos.iPos-startPos;
   369 
   369 
   370 	if(FatMount().IsRuggedFSys() && pos+(TUint)aLength > FCB_FileSize())
   370 	if(!IsSequentialMode() && FatMount().IsRuggedFSys() && pos+(TUint)aLength > FCB_FileSize())
   371 		{
   371 		{
   372 		WriteFileSizeL(pos+aLength);
   372 		WriteFileSizeL(pos+aLength);
   373 		}
   373 		}
   374 
   374 
   375 	}
   375 	}
   377 
   377 
   378 void CFatFileCB::WriteL(TInt aFilePos,TInt& aLength,const TAny* aSrc,const RMessagePtr2& aMessage)
   378 void CFatFileCB::WriteL(TInt aFilePos,TInt& aLength,const TAny* aSrc,const RMessagePtr2& aMessage)
   379 	{
   379 	{
   380 	WriteL(TInt64(aFilePos),aLength,(TDesC8*) aSrc,aMessage, 0);
   380 	WriteL(TInt64(aFilePos),aLength,(TDesC8*) aSrc,aMessage, 0);
   381 	}
   381 	}
   382 
       
   383 
   382 
   384 
   383 
   385 //-----------------------------------------------------------------------------
   384 //-----------------------------------------------------------------------------
   386 
   385 
   387 void CFatFileCB::ResizeIndex(TInt aNewMult,TUint aNewSize)
   386 void CFatFileCB::ResizeIndex(TInt aNewMult,TUint aNewSize)
   500 	
   499 	
   501 	//-- max. file size for FAT is 4GB-1
   500 	//-- max. file size for FAT is 4GB-1
   502 	if (I64HIGH(aSize))
   501 	if (I64HIGH(aSize))
   503 		User::Leave(KErrNotSupported);
   502 		User::Leave(KErrNotSupported);
   504 
   503 
   505     DoSetSizeL(I64LOW(aSize), FatMount().IsRuggedFSys());
   504 	DoSetSizeL(I64LOW(aSize), FatMount().IsRuggedFSys());
   506 	}
   505 	}
   507 
   506 
   508 
   507 
   509 void CFatFileCB::SetSizeL(TInt aSize)
   508 void CFatFileCB::SetSizeL(TInt aSize)
   510 	{
   509 	{
   518 void CFatFileCB::DoShrinkFileToZeroSizeL()
   517 void CFatFileCB::DoShrinkFileToZeroSizeL()
   519     {
   518     {
   520 	    ASSERT(FCB_FileSize());
   519 	    ASSERT(FCB_FileSize());
   521         ASSERT(FileSizeModified());
   520         ASSERT(FileSizeModified());
   522         
   521         
   523             ClearIndex(0); //-- clear seek index array
   522         ClearIndex(0); // Clear seek index array
   524 		
   523 		
   525         //-- update file dir. entry
   524         //-- update file dir. entry
   526         const TUint32 cluster = FCB_StartCluster();
   525         const TUint32 cluster = FCB_StartCluster();
   527 		FCB_SetStartCluster(0);
   526 		FCB_SetStartCluster(0);
   528 		FCB_SetFileSize(0);
   527 		FCB_SetFileSize(0);
   606 			iCurrentPos=currentPos;
   605 			iCurrentPos=currentPos;
   607 			}
   606 			}
   608 	
   607 	
   609 		FAT().FlushL();
   608 		FAT().FlushL();
   610 		
   609 		
   611         if(aForceCachesFlush)			// write file size if increasing
   610         if(!IsSequentialMode() && aForceCachesFlush)	// Write file size directly to its dir. entry if a cache flush
   612 			WriteFileSizeL(aNewSize);
   611 			WriteFileSizeL(aNewSize);				// is needed and rugged FAT is not ignored by client
   613 		}
   612 		}
   614 
   613 
   615 	}
   614 	}
   616 
   615 
   617 //-----------------------------------------------------------------------------
   616 //-----------------------------------------------------------------------------
   882 	else
   881 	else
   883 		return KErrNone;
   882 		return KErrNone;
   884 	}
   883 	}
   885 
   884 
   886 
   885 
   887 
       
   888 TInt CFatFileCB::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
   886 TInt CFatFileCB::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
   889 	{
   887 	{
   890 	switch(aInterfaceId)
   888 	switch(aInterfaceId)
   891 		{
   889 		{
   892 		case EExtendedFileInterface:
   890 		case EExtendedFileInterface:
   904 			return CFileCB::GetInterface(aInterfaceId,aInterface,aInput);
   902 			return CFileCB::GetInterface(aInterfaceId,aInterface,aInput);
   905 		}
   903 		}
   906 	}
   904 	}
   907 
   905 
   908 
   906 
   909 
       
   910 
       
   911 /**
   907 /**
   912     Overwrites file's start cluster (iStartCluster) in its directory entry.
   908     Overwrites file's start cluster (iStartCluster) in its directory entry.
   913 */
   909 */
   914 void CFatFileCB::FlushStartClusterL()
   910 void CFatFileCB::FlushStartClusterL()
   915 	{
   911 	{