23 |
23 |
24 |
24 |
25 //--------------------------------------------------------------------------------------------------------------------------------------- |
25 //--------------------------------------------------------------------------------------------------------------------------------------- |
26 |
26 |
27 |
27 |
28 TFatDriveInterface::TFatDriveInterface() |
28 TDriveInterface::TDriveInterface() |
29 :iMount(NULL) |
29 :iMount(NULL) |
30 { |
30 { |
31 } |
31 } |
32 |
32 |
33 /** |
33 /** |
34 Initialise the interface object. |
34 Initialise the interface object. |
35 @param aMount the CFatMountCB that owns this object |
35 @param aMount the CFatMountCB that owns this object |
36 */ |
36 */ |
37 TBool TFatDriveInterface::Init(CFatMountCB* aMount) |
37 TBool TDriveInterface::Init(CFatMountCB* aMount) |
38 { |
38 { |
39 ASSERT(aMount); |
39 ASSERT(aMount); |
40 iMount = aMount; |
40 iMount = aMount; |
41 aMount->LocalDrive()->SetMount(aMount); |
41 aMount->LocalDrive()->SetMount(aMount); |
42 return iProxyDrive.Init(aMount->LocalDrive()); |
42 return iProxyDrive.Init(aMount->LocalDrive()); |
43 } |
43 } |
44 |
44 |
45 /** |
45 /** |
46 pseudo-destructor. |
46 pseudo-destructor. |
47 */ |
47 */ |
48 void TFatDriveInterface::Close() |
48 void TDriveInterface::Close() |
49 { |
49 { |
50 if(iMount) |
50 if(iMount) |
51 iMount->LocalDrive()->SetMount(NULL); |
51 iMount->LocalDrive()->SetMount(NULL); |
52 iMount = NULL; |
52 iMount = NULL; |
53 } |
53 } |
113 @return KErrNotReady - non-critical error |
113 @return KErrNotReady - non-critical error |
114 @return KErrCorrupt - an illegal write is detected |
114 @return KErrCorrupt - an illegal write is detected |
115 @return KErrBadPower - failure due to low power |
115 @return KErrBadPower - failure due to low power |
116 |
116 |
117 */ |
117 */ |
118 TInt TFatDriveInterface::ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const |
118 TInt TDriveInterface::ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const |
119 { |
119 { |
120 //__PRINT2(_L("#=+++ Read_nc2: pos:%LU, len:%u"), aPos, aLength); |
120 //__PRINT2(_L("#=+++ Read_nc2: pos:%LU, len:%u"), aPos, aLength); |
121 |
121 |
122 TInt nRes = KErrNone; |
122 TInt nRes = KErrNone; |
123 TInt cntRetry = KMaxRecoverableRetries; |
123 TInt cntRetry = KMaxRecoverableRetries; |
196 @return KErrNotReady - non-critical error |
196 @return KErrNotReady - non-critical error |
197 @return KErrBadPower - write not attempted due to low batteries |
197 @return KErrBadPower - write not attempted due to low batteries |
198 @return KErrCorrupt - an illegal write is detected |
198 @return KErrCorrupt - an illegal write is detected |
199 @return KErrAccessDenied - write to protected media |
199 @return KErrAccessDenied - write to protected media |
200 */ |
200 */ |
201 TInt TFatDriveInterface::WriteNonCritical(TInt64 aPos, TInt aLength, const TAny* aSrc, const RMessagePtr2 &aMessage, TInt anOffset) |
201 TInt TDriveInterface::WriteNonCritical(TInt64 aPos, TInt aLength, const TAny* aSrc, const RMessagePtr2 &aMessage, TInt anOffset) |
202 { |
202 { |
203 //__PRINT2(_L("#=+++ Write_NC: pos:%LU, len:%u"), aPos, aLength); |
203 //__PRINT2(_L("#=+++ Write_NC: pos:%LU, len:%u"), aPos, aLength); |
204 |
204 |
205 |
205 |
206 TInt nRes = KErrNone; |
206 TInt nRes = KErrNone; |
340 @return ERetry - Attempt operation again |
340 @return ERetry - Attempt operation again |
341 @return KErrAbort - User aborted notifier |
341 @return KErrAbort - User aborted notifier |
342 @return KErrAccessDenied - media is read only |
342 @return KErrAccessDenied - media is read only |
343 @return KErrCorrupt - cf-card is corrupt |
343 @return KErrCorrupt - cf-card is corrupt |
344 */ |
344 */ |
345 TInt TFatDriveInterface::HandleCriticalError(TInt aResult) const |
345 TInt TDriveInterface::HandleCriticalError(TInt aResult) const |
346 { |
346 { |
347 __PRINT2(_L("TFatDriveInterface::HandleCriticalError drv:%d, code:%d"), iMount->DriveNumber(),aResult); |
347 __PRINT2(_L("TDriveInterface::HandleCriticalError drv:%d, code:%d"), iMount->DriveNumber(),aResult); |
348 |
348 |
349 TLocaleMessage line1; |
349 TLocaleMessage line1; |
350 TLocaleMessage line2; |
350 TLocaleMessage line2; |
351 |
351 |
352 TInt r=KErrAbort; |
352 TInt r=KErrAbort; |
454 @return ERetry - retry write |
454 @return ERetry - retry write |
455 @return KErrCorrupt - media is corrupt |
455 @return KErrCorrupt - media is corrupt |
456 @return KErrBadPower - low power failure |
456 @return KErrBadPower - low power failure |
457 @return KErrNotReady - non-critical error |
457 @return KErrNotReady - non-critical error |
458 */ |
458 */ |
459 TInt TFatDriveInterface::HandleRecoverableError(TInt aResult) const |
459 TInt TDriveInterface::HandleRecoverableError(TInt aResult) const |
460 { |
460 { |
461 __PRINT2(_L("TFatDriveInterface::HandleRecoverableError drv:%d, code:%d"), iMount->DriveNumber(),aResult); |
461 __PRINT2(_L("TDriveInterface::HandleRecoverableError drv:%d, code:%d"), iMount->DriveNumber(),aResult); |
462 |
462 |
463 if (aResult==KErrAccessDenied) |
463 if (aResult==KErrAccessDenied) |
464 return(KErrAccessDenied); |
464 return(KErrAccessDenied); |
465 if (aResult == KErrLocked) |
465 if (aResult == KErrLocked) |
466 return KErrLocked; |
466 return KErrLocked; |
507 |
507 |
508 |
508 |
509 |
509 |
510 //--------------------------------------------------------------------------------------------------------------------------------------- |
510 //--------------------------------------------------------------------------------------------------------------------------------------- |
511 |
511 |
512 TFatDriveInterface::XProxyDriveWrapper::XProxyDriveWrapper() |
512 TDriveInterface::XProxyDriveWrapper::XProxyDriveWrapper() |
513 :iLocalDrive(0) |
513 :iLocalDrive(0) |
514 { |
514 { |
515 TInt nRes = iLock.CreateLocal(); |
515 TInt nRes = iLock.CreateLocal(); |
516 ASSERT(nRes == KErrNone); |
516 ASSERT(nRes == KErrNone); |
517 (void)nRes; |
517 (void)nRes; |
518 } |
518 } |
519 |
519 |
520 |
520 |
521 TFatDriveInterface::XProxyDriveWrapper::~XProxyDriveWrapper() |
521 TDriveInterface::XProxyDriveWrapper::~XProxyDriveWrapper() |
522 { |
522 { |
523 iLock.Close(); |
523 iLock.Close(); |
524 } |
524 } |
525 |
525 |
526 /** |
526 /** |
527 Initialise interface wrapper. |
527 Initialise interface wrapper. |
528 @param aProxyDrive pointer to the raw drive access interface |
528 @param aProxyDrive pointer to the raw drive access interface |
529 @return true on success |
529 @return true on success |
530 */ |
530 */ |
531 TBool TFatDriveInterface::XProxyDriveWrapper::Init(CProxyDrive* aProxyDrive) |
531 TBool TDriveInterface::XProxyDriveWrapper::Init(CProxyDrive* aProxyDrive) |
532 { |
532 { |
533 ASSERT(aProxyDrive); |
533 ASSERT(aProxyDrive); |
534 if(!iLock.Handle()) //-- the mutex must have been created by constructor |
534 if(!iLock.Handle()) //-- the mutex must have been created by constructor |
535 return EFalse; |
535 return EFalse; |
536 |
536 |
537 iLocalDrive = aProxyDrive; |
537 iLocalDrive = aProxyDrive; |
538 return ETrue; |
538 return ETrue; |
539 } |
539 } |
540 |
540 |
541 //-- see original TFatDriveInterface methods |
541 //-- see original TDriveInterface methods |
542 |
542 |
543 TInt TFatDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const |
543 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const |
544 { |
544 { |
545 EnterCriticalSection(); |
545 EnterCriticalSection(); |
546 TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg, aMessage.Handle(), anOffset); |
546 TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg, aMessage.Handle(), anOffset); |
547 LeaveCriticalSection(); |
547 LeaveCriticalSection(); |
548 return nRes; |
548 return nRes; |
549 } |
549 } |
550 |
550 |
551 TInt TFatDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const |
551 TInt TDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const |
552 { |
552 { |
553 EnterCriticalSection(); |
553 EnterCriticalSection(); |
554 TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg); |
554 TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg); |
555 LeaveCriticalSection(); |
555 LeaveCriticalSection(); |
556 return nRes; |
556 return nRes; |
557 } |
557 } |
558 |
558 |
559 TInt TFatDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset) |
559 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset) |
560 { |
560 { |
561 EnterCriticalSection(); |
561 EnterCriticalSection(); |
562 TInt nRes = iLocalDrive->Write(aPos, aLength, aSrc, aMessage.Handle(), anOffset); |
562 TInt nRes = iLocalDrive->Write(aPos, aLength, aSrc, aMessage.Handle(), anOffset); |
563 LeaveCriticalSection(); |
563 LeaveCriticalSection(); |
564 return nRes; |
564 return nRes; |
565 } |
565 } |
566 |
566 |
567 TInt TFatDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos, const TDesC8& aSrc) |
567 TInt TDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos, const TDesC8& aSrc) |
568 { |
568 { |
569 EnterCriticalSection(); |
569 EnterCriticalSection(); |
570 TInt nRes = iLocalDrive->Write(aPos, aSrc); |
570 TInt nRes = iLocalDrive->Write(aPos, aSrc); |
571 LeaveCriticalSection(); |
571 LeaveCriticalSection(); |
572 return nRes; |
572 return nRes; |
573 } |
573 } |
574 |
574 |
575 TInt TFatDriveInterface::XProxyDriveWrapper::GetLastErrorInfo(TDes8& aErrorInfo) const |
575 TInt TDriveInterface::XProxyDriveWrapper::GetLastErrorInfo(TDes8& aErrorInfo) const |
576 { |
576 { |
577 EnterCriticalSection(); |
577 EnterCriticalSection(); |
578 TInt nRes = iLocalDrive->GetLastErrorInfo(aErrorInfo); |
578 TInt nRes = iLocalDrive->GetLastErrorInfo(aErrorInfo); |
579 LeaveCriticalSection(); |
579 LeaveCriticalSection(); |
580 return nRes; |
580 return nRes; |
581 } |
581 } |
582 |
582 |
583 TInt TFatDriveInterface::XProxyDriveWrapper::Caps(TDes8& anInfo) const |
583 TInt TDriveInterface::XProxyDriveWrapper::Caps(TDes8& anInfo) const |
584 { |
584 { |
585 EnterCriticalSection(); |
585 EnterCriticalSection(); |
586 TInt nRes = iLocalDrive->Caps(anInfo); |
586 TInt nRes = iLocalDrive->Caps(anInfo); |
587 LeaveCriticalSection(); |
587 LeaveCriticalSection(); |
588 return nRes; |
588 return nRes; |