userlibandfileserver/fileserver/sfat32/sl_drv.cpp
changeset 140 2ac1c5c27758
parent 90 947f0dc9f7a8
child 176 af6ec97d9189
equal deleted inserted replaced
135:5e441a173c63 140:2ac1c5c27758
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    44 
    44 
    45 /**
    45 /**
    46     Close the interface to the media driver
    46     Close the interface to the media driver
    47 */
    47 */
    48 void TDriveInterface::Close()
    48 void TDriveInterface::Close()
    49 {
    49 {	 
    50 	 if(iMount)
    50 	 if((iMount != NULL) && (iMount->LocalDrive() != NULL))
    51 		{
    51 		{
    52 		iMount->LocalDrive()->SetMount(NULL);
    52 		iMount->LocalDrive()->SetMount(NULL);
    53         }
    53 		}
    54 
       
    55      iMount = NULL;
    54      iMount = NULL;
    56 }
    55 }
    57 
    56 
    58 //---------------------------------------------------------------------------------------------------------------------------------------
    57 //---------------------------------------------------------------------------------------------------------------------------------------
    59 
    58 
   116     @return KErrNotReady - non-critical error
   115     @return KErrNotReady - non-critical error
   117     @return KErrCorrupt - an illegal write is detected
   116     @return KErrCorrupt - an illegal write is detected
   118     @return KErrBadPower - failure due to low power
   117     @return KErrBadPower - failure due to low power
   119 
   118 
   120 */
   119 */
   121 TInt TDriveInterface::ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   120 TInt TDriveInterface::ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset, TUint aFlag) const
   122 {
   121 {
   123     //__PRINT2(_L("#=+++ Read_nc2: pos:%LU, len:%u"), aPos, aLength);
   122     //__PRINT2(_L("#=+++ Read_nc2: pos:%LU, len:%u"), aPos, aLength);
   124 
   123 
   125     TInt nRes = KErrNone;
   124     TInt nRes = KErrNone;
   126     TInt cntRetry = KMaxRecoverableRetries;
   125     TInt cntRetry = KMaxRecoverableRetries;
   127 
   126 
   128     for(;;)
   127     for(;;)
   129     {
   128     {
   130         nRes = iProxyDrive.Read(aPos, aLength, aTrg, aMessage, anOffset);
   129         nRes = iProxyDrive.Read(aPos, aLength, aTrg, aMessage, anOffset, aFlag);
   131         if (nRes==KErrNone)
   130         if (nRes==KErrNone)
   132             break;
   131             break;
   133 
   132 
   134         __PRINT4(_L("TDriveInterface::ReadNonCritical() Failure! drv:%d aPosl=%d len=%d anOffset=%d"), iMount->DriveNumber(), aPos,aLength, anOffset);
   133         __PRINT4(_L("TDriveInterface::ReadNonCritical() Failure! drv:%d aPosl=%d len=%d anOffset=%d"), iMount->DriveNumber(), aPos,aLength, anOffset);
   135         
   134         
   199     @return KErrNotReady - non-critical error
   198     @return KErrNotReady - non-critical error
   200     @return KErrBadPower - write not attempted due to low batteries
   199     @return KErrBadPower - write not attempted due to low batteries
   201     @return KErrCorrupt - an illegal write is detected
   200     @return KErrCorrupt - an illegal write is detected
   202     @return KErrAccessDenied - write to protected media
   201     @return KErrAccessDenied - write to protected media
   203 */
   202 */
   204 TInt TDriveInterface::WriteNonCritical(TInt64 aPos, TInt aLength, const TAny* aSrc, const RMessagePtr2 &aMessage, TInt anOffset)
   203 TInt TDriveInterface::WriteNonCritical(TInt64 aPos, TInt aLength, const TAny* aSrc, const RMessagePtr2 &aMessage, TInt anOffset, TUint aFlag)
   205 {
   204 {
   206     //__PRINT2(_L("#=+++ Write_NC: pos:%LU, len:%u"), aPos, aLength);
   205     //__PRINT2(_L("#=+++ Write_NC: pos:%LU, len:%u"), aPos, aLength);
   207 
   206 
   208     
   207     
   209     TInt nRes = KErrNone;
   208     TInt nRes = KErrNone;
   210     TInt cntRetry = KMaxRecoverableRetries;
   209     TInt cntRetry = KMaxRecoverableRetries;
   211 
   210 
   212     for(;;)
   211     for(;;)
   213     {
   212     {
   214         iMount->OpenMountForWrite(); //-- make a callback to CFatMountCB to perform some actions on 1st write.
   213         iMount->OpenMountForWrite(); //-- make a callback to CFatMountCB to perform some actions on 1st write.
   215         nRes = iProxyDrive.Write(aPos, aLength, aSrc, aMessage, anOffset);
   214         nRes = iProxyDrive.Write(aPos, aLength, aSrc, aMessage, anOffset, aFlag);
   216         if (nRes==KErrNone)
   215         if (nRes==KErrNone)
   217             break;
   216             break;
   218 
   217 
   219         __PRINT4(_L("TDriveInterface::WriteNonCritical() failure! drv:%d, Pos=%LU len=%d anOffset=%d"), iMount->DriveNumber(), aPos, aLength, anOffset);
   218         __PRINT4(_L("TDriveInterface::WriteNonCritical() failure! drv:%d, Pos=%LU len=%d anOffset=%d"), iMount->DriveNumber(), aPos, aLength, anOffset);
   220         
   219         
   541     return ETrue;
   540     return ETrue;
   542 }
   541 }
   543 
   542 
   544 //-- see original TDriveInterface methods
   543 //-- see original TDriveInterface methods
   545 
   544 
   546 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   545 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset, TUint aFlag) const
   547 {
   546 {
   548     EnterCriticalSection();
   547     EnterCriticalSection();
   549     TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg, aMessage.Handle(), anOffset);
   548     TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg, aMessage.Handle(), anOffset, aFlag);
   550     LeaveCriticalSection();
   549     LeaveCriticalSection();
   551     return nRes;
   550     return nRes;
   552 }
   551 }
   553        
   552        
   554 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const
   553 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const
   557     TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg);
   556     TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg);
   558     LeaveCriticalSection();
   557     LeaveCriticalSection();
   559     return nRes;
   558     return nRes;
   560 }
   559 }
   561 
   560 
   562 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
   561 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset, TUint aFlag)
   563 {
   562 {
   564     EnterCriticalSection();
   563     EnterCriticalSection();
   565     TInt nRes = iLocalDrive->Write(aPos, aLength, aSrc, aMessage.Handle(), anOffset);
   564     TInt nRes = iLocalDrive->Write(aPos, aLength, aSrc, aMessage.Handle(), anOffset, aFlag);
   566     LeaveCriticalSection();
   565     LeaveCriticalSection();
   567     return nRes;
   566     return nRes;
   568 }
   567 }
   569 
   568 
   570 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos, const TDesC8& aSrc)
   569 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos, const TDesC8& aSrc)