sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\ext\bitext.cpp sl@0: // extension to do XOR on every byte on 32 byte boundary read or written to media subsystem in same thread sl@0: // therefore RFile::Read/Write does not have this operation carried out on it sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: class CBitExtProxyDrive : public CBaseExtProxyDrive sl@0: { sl@0: public: sl@0: static CBitExtProxyDrive* NewL(CProxyDrive* aProxyDrive, CMountCB* aMount); sl@0: ~CBitExtProxyDrive(); sl@0: public: sl@0: virtual TInt Initialise(); sl@0: virtual TInt Dismounted(); sl@0: virtual TInt Enlarge(TInt aLength); sl@0: virtual TInt ReduceSize(TInt aPos, TInt aLength); sl@0: virtual TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset); sl@0: virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg); sl@0: virtual TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset); sl@0: virtual TInt Write(TInt64 aPos,const TDesC8& aSrc); sl@0: virtual TInt Format(TFormatInfo& anInfo); sl@0: virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); sl@0: private: sl@0: CBitExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount); sl@0: private: sl@0: TInt iReadThread; sl@0: TInt iRead; sl@0: TInt iWriteThread; sl@0: TInt iWrite; sl@0: TInt iFormat; sl@0: }; sl@0: sl@0: class CBitProxyDriveFactory : public CProxyDriveFactory sl@0: { sl@0: public: sl@0: CBitProxyDriveFactory(); sl@0: virtual TInt Install(); sl@0: virtual CProxyDrive* NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount); sl@0: }; sl@0: sl@0: const TUint8 KBitMask=0xcc; sl@0: const TInt KChangePosMask=0x0000001f; sl@0: sl@0: LOCAL_C void DoXOR(TInt aPos,TInt aLength,TUint8* aPtr) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: for(TInt i=0;iDes(); sl@0: ptr.Copy(aSrc); sl@0: sl@0: DoXOR(I64INT(aPos), ptr.Length(), (TUint8*)ptr.Ptr()); sl@0: TInt r = CBaseExtProxyDrive::Write(aPos, ptr); sl@0: sl@0: delete buf; sl@0: sl@0: return(r); sl@0: } sl@0: sl@0: TInt CBitExtProxyDrive::Format(TFormatInfo& anInfo) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: ++iFormat; sl@0: return(CBaseExtProxyDrive::Format(anInfo)); sl@0: } sl@0: sl@0: sl@0: TInt CBitExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput) sl@0: { sl@0: switch(aInterfaceId) sl@0: { sl@0: // file caching supported, so pass query on to next extension sl@0: case ELocalBufferSupport: sl@0: return CBaseExtProxyDrive::LocalBufferSupport(); sl@0: sl@0: default: sl@0: return CBaseExtProxyDrive::GetInterface(aInterfaceId, aInterface, aInput); sl@0: } sl@0: } sl@0: sl@0: CBitProxyDriveFactory::CBitProxyDriveFactory() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: RDebug::Print(_L("CBitProxyDriveFactory::CBitProxyDriveFactory")); sl@0: } sl@0: sl@0: TInt CBitProxyDriveFactory::Install() sl@0: // sl@0: // sl@0: // sl@0: { sl@0: _LIT(KBitName,"Bitchange"); sl@0: return(SetName(&KBitName)); sl@0: } sl@0: sl@0: sl@0: CProxyDrive* CBitProxyDriveFactory::NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: return(CBitExtProxyDrive::NewL(aProxy,aMount)); sl@0: } sl@0: sl@0: extern "C" { sl@0: sl@0: EXPORT_C CProxyDriveFactory* CreateFileSystem() sl@0: // sl@0: // Create a new file system sl@0: // sl@0: { sl@0: return(new CBitProxyDriveFactory()); sl@0: } sl@0: } sl@0: