sl@0: // Copyright (c) 1997-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\fsstress\t_remfil.cpp sl@0: // sl@0: // sl@0: sl@0: #if defined(_UNICODE) sl@0: #if !defined(UNICODE) sl@0: #define UNICODE sl@0: #endif sl@0: #endif sl@0: sl@0: /* sl@0: #define WIN32_LEAN_AND_MEAN sl@0: #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union sl@0: #include sl@0: #pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union sl@0: #include sl@0: */ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "t_remfsy.h" sl@0: sl@0: sl@0: sl@0: ////////////////////////////////////////////////////////////////////////// sl@0: // CRemoteFileCB // sl@0: ////////////////////////////////////////////////////////////////////////// sl@0: sl@0: CRemoteFileCB::CRemoteFileCB() sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: sl@0: // iCurrentPos=0; sl@0: // iAttPending=EFalse; sl@0: // iWinHandle=NULL; sl@0: __DECLARE_NAME(_S("CRemoteFileCB")); sl@0: } sl@0: sl@0: CRemoteFileCB::~CRemoteFileCB() sl@0: // sl@0: // Destructor sl@0: // sl@0: { sl@0: sl@0: if (iAtt&KEntryAttModified) sl@0: { sl@0: TRAP_IGNORE(FlushDataL()); sl@0: // if (ret!=KErrNone) // Can fail if floppy disk is removed sl@0: // Panic(EFileClose); // Ignore error sl@0: } sl@0: // if (iWinHandle!=NULL && CloseHandle(iWinHandle)==FALSE) sl@0: // Panic(EFileClose); sl@0: } sl@0: sl@0: TBool CRemoteFileCB::IsRomDrive() const sl@0: // sl@0: // Returns ETrue if the drive number == EDriveZ sl@0: // sl@0: { sl@0: return(((CRemoteFileCB*)this)->Mount().Drive().DriveNumber()==EDriveZ); sl@0: } sl@0: sl@0: sl@0: void CRemoteFileCB::CheckPos(TInt /*aPos*/) sl@0: // sl@0: // Check that the file is positioned correctly. sl@0: // Dummy implementation sl@0: // sl@0: {} sl@0: sl@0: sl@0: void CRemoteFileCB::ReadL(TInt /*aPos*/,TInt& /*aLength*/,const TAny* /*aDes*/,const RMessagePtr2& /*aMessage*/) sl@0: // sl@0: // Read from the file sl@0: // Dummy implementation of a pure virtual function sl@0: // sl@0: { sl@0: User::After(200000); // Wait 0.2 seconds sl@0: } sl@0: sl@0: sl@0: void CRemoteFileCB::WriteL(TInt /*aPos*/,TInt& /*aLength*/,const TAny* /*aDes*/,const RMessagePtr2& /*aMessage*/) sl@0: // sl@0: // Write to the file sl@0: // sl@0: { sl@0: User::After(200000); // Wait 0.2 seconds sl@0: /* sl@0: TBuf8<0x100> buf; sl@0: if (IsRomDrive()) sl@0: User::Leave(KErrAccessDenied); sl@0: CheckPos(aPos); sl@0: TInt pos=0; sl@0: TInt len=aLength; sl@0: RThread thread; sl@0: while (len) sl@0: { sl@0: TInt s=Min(len,buf.MaxLength()); sl@0: thread.ReadL(aDes,buf,pos); sl@0: // Reading from client thread descriptor to fileserver thread sl@0: sl@0: // printf(iConsole,_L("%S\n"),&buf); sl@0: sl@0: len-=s; sl@0: pos+=s; sl@0: } sl@0: aLength=pos; sl@0: iCurrentPos=aPos+pos; sl@0: */ sl@0: } sl@0: sl@0: TInt CRemoteFileCB::Address(TInt& /*aPos*/) const sl@0: // sl@0: // If ROM file, do a memory map and return the address sl@0: // Dummy implementation sl@0: // sl@0: { sl@0: return(KErrNone); sl@0: } sl@0: sl@0: void CRemoteFileCB::SetSizeL(TInt /*aSize*/) sl@0: // sl@0: // Set the file size sl@0: // Dummy implementation of a pure virtual function sl@0: // sl@0: { sl@0: User::After(200000); // Wait 0.2 seconds sl@0: } sl@0: sl@0: void CRemoteFileCB::SetEntryL(const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/) sl@0: // sl@0: // Set the entry's attributes and modified time sl@0: // Dummy implementation of a pure virtual function sl@0: // sl@0: { sl@0: User::After(200000); // Wait 0.2 seconds sl@0: } sl@0: sl@0: sl@0: void CRemoteFileCB::FlushAllL() sl@0: // sl@0: // Commit any buffered date to the media. sl@0: // sl@0: { sl@0: sl@0: FlushDataL(); sl@0: } sl@0: sl@0: sl@0: void CRemoteFileCB::FlushDataL() sl@0: // sl@0: // Commit any buffered date to the media sl@0: // Dummy implementation of a pure virtual function sl@0: // sl@0: {} sl@0: sl@0: void CRemoteFileCB::RenameL(const TDesC& /*aNewName*/) sl@0: // sl@0: // Rename the file while open sl@0: // Dummy implementation of a pure virtual function sl@0: // sl@0: { sl@0: User::After(200000); // Wait 0.2 seconds sl@0: } sl@0: sl@0: /* sl@0: LOCAL_C void printf(RConsole& aConsole, TRefByValue aFmt,...) sl@0: // sl@0: // Print to the console sl@0: // sl@0: { sl@0: sl@0: if (aConsole.Handle()==KNullHandle) sl@0: { sl@0: TInt r=aConsole.Init(_L("RemoteFSys"),TSize(KDefaultConsWidth,KDefaultConsHeight)); sl@0: __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Open-Console"),0)); sl@0: r=aConsole.Control(_L("+Maximize +NewLine -Lock -Wrap")); sl@0: __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Config-Console"),0)); sl@0: } sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: TBuf<0x100> aBuf; sl@0: aBuf.AppendFormatList(aFmt,list); sl@0: TInt r=aConsole.Write(aBuf); sl@0: __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Write-Console"),0)); sl@0: } sl@0: */