kerneltest/f32test/fsstress/t_remfil.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32test\fsstress\t_remfil.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #if defined(_UNICODE)
       
    19 #if !defined(UNICODE)
       
    20 #define UNICODE
       
    21 #endif
       
    22 #endif
       
    23 
       
    24 /*
       
    25 #define WIN32_LEAN_AND_MEAN
       
    26 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
       
    27  #include <windows.h>
       
    28 #pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union
       
    29 #include <stdlib.h>
       
    30 */
       
    31 #include <f32file.h>
       
    32 #include <f32fsys.h>
       
    33 #include <f32ver.h>
       
    34 #include <e32twin.h>
       
    35 #include <e32uid.h>
       
    36 
       
    37 #include "t_remfsy.h"
       
    38 
       
    39 
       
    40 
       
    41 //////////////////////////////////////////////////////////////////////////
       
    42 //								CRemoteFileCB							//
       
    43 //////////////////////////////////////////////////////////////////////////	
       
    44 
       
    45 CRemoteFileCB::CRemoteFileCB()
       
    46 //
       
    47 // Constructor
       
    48 //
       
    49 	{
       
    50 
       
    51 //	iCurrentPos=0;
       
    52 //	iAttPending=EFalse;
       
    53 //	iWinHandle=NULL;
       
    54 	__DECLARE_NAME(_S("CRemoteFileCB"));
       
    55 	}
       
    56 
       
    57 CRemoteFileCB::~CRemoteFileCB()
       
    58 //
       
    59 // Destructor
       
    60 //
       
    61 	{
       
    62 
       
    63 	if (iAtt&KEntryAttModified)
       
    64 		{
       
    65 		TRAP_IGNORE(FlushDataL());
       
    66 //		if (ret!=KErrNone)		//	Can fail if floppy disk is removed
       
    67 //			Panic(EFileClose);	//	Ignore error
       
    68 		}
       
    69 //	if (iWinHandle!=NULL && CloseHandle(iWinHandle)==FALSE)
       
    70 //		Panic(EFileClose);
       
    71 	}
       
    72 
       
    73 TBool CRemoteFileCB::IsRomDrive() const
       
    74 //
       
    75 // Returns ETrue if the drive number == EDriveZ
       
    76 //
       
    77 	{
       
    78 	return(((CRemoteFileCB*)this)->Mount().Drive().DriveNumber()==EDriveZ);
       
    79 	}
       
    80 
       
    81 
       
    82 void CRemoteFileCB::CheckPos(TInt /*aPos*/)
       
    83 //
       
    84 //	Check that the file is positioned correctly.
       
    85 //	Dummy implementation
       
    86 //
       
    87 	{}
       
    88 
       
    89 
       
    90  void CRemoteFileCB::ReadL(TInt /*aPos*/,TInt& /*aLength*/,const TAny* /*aDes*/,const RMessagePtr2& /*aMessage*/)
       
    91 //
       
    92 //	Read from the file
       
    93 //	Dummy implementation of a pure virtual function
       
    94 //
       
    95 	{
       
    96 	User::After(200000);	//	Wait 0.2 seconds
       
    97 	}
       
    98 
       
    99 
       
   100 void CRemoteFileCB::WriteL(TInt /*aPos*/,TInt& /*aLength*/,const TAny* /*aDes*/,const RMessagePtr2& /*aMessage*/)
       
   101 //
       
   102 //	Write to the file
       
   103 //
       
   104 	{
       
   105 	User::After(200000);	//	Wait 0.2 seconds	
       
   106 /*
       
   107 	TBuf8<0x100> buf;
       
   108 	if (IsRomDrive())
       
   109 		User::Leave(KErrAccessDenied);
       
   110 	CheckPos(aPos);
       
   111 	TInt pos=0;
       
   112 	TInt len=aLength;
       
   113 	RThread thread;
       
   114 	while (len)
       
   115 		{
       
   116 		TInt s=Min(len,buf.MaxLength());
       
   117 		thread.ReadL(aDes,buf,pos); 
       
   118 	//	Reading from client thread descriptor to fileserver thread
       
   119 		
       
   120 	//	printf(iConsole,_L("%S\n"),&buf);
       
   121 		
       
   122 		len-=s;
       
   123 		pos+=s;
       
   124 		}
       
   125 	aLength=pos;
       
   126 	iCurrentPos=aPos+pos;
       
   127 */
       
   128 	}
       
   129 
       
   130 TInt CRemoteFileCB::Address(TInt& /*aPos*/) const
       
   131 //
       
   132 //	If ROM file, do a memory map and return the address
       
   133 //	Dummy implementation
       
   134 //
       
   135 	{
       
   136 	return(KErrNone);
       
   137 	}
       
   138 
       
   139 void CRemoteFileCB::SetSizeL(TInt /*aSize*/)
       
   140 //
       
   141 //	Set the file size
       
   142 //	Dummy implementation of a pure virtual function
       
   143 //
       
   144 	{
       
   145 	User::After(200000);	//	Wait 0.2 seconds
       
   146 	}
       
   147 
       
   148 void CRemoteFileCB::SetEntryL(const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
       
   149 //
       
   150 //	Set the entry's attributes and modified time
       
   151 //	Dummy implementation of a pure virtual function
       
   152 //
       
   153 	{
       
   154 	User::After(200000);	//	Wait 0.2 seconds
       
   155 	}
       
   156 
       
   157 
       
   158 void CRemoteFileCB::FlushAllL()
       
   159 //
       
   160 // Commit any buffered date to the media.
       
   161 //
       
   162 	{
       
   163 	
       
   164 	FlushDataL();
       
   165 	}
       
   166 
       
   167 
       
   168 void CRemoteFileCB::FlushDataL()
       
   169 //
       
   170 //	Commit any buffered date to the media
       
   171 //	Dummy implementation of a pure virtual function
       
   172 //
       
   173 	{}
       
   174 
       
   175 void CRemoteFileCB::RenameL(const TDesC& /*aNewName*/)
       
   176 //
       
   177 //	Rename the file while open
       
   178 //	Dummy implementation of a pure virtual function
       
   179 //
       
   180 	{
       
   181 	User::After(200000);	//	Wait 0.2 seconds
       
   182 	}
       
   183 
       
   184 /*
       
   185 LOCAL_C void printf(RConsole& aConsole, TRefByValue<const TDesC> aFmt,...)
       
   186 //
       
   187 // Print to the console
       
   188 //
       
   189 	{
       
   190 
       
   191 	if (aConsole.Handle()==KNullHandle)
       
   192 		{
       
   193 		TInt r=aConsole.Init(_L("RemoteFSys"),TSize(KDefaultConsWidth,KDefaultConsHeight));
       
   194 		__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Open-Console"),0));
       
   195 		r=aConsole.Control(_L("+Maximize +NewLine -Lock -Wrap"));
       
   196 		__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Config-Console"),0));
       
   197 		}
       
   198 	VA_LIST list;
       
   199 	VA_START(list,aFmt);
       
   200 	TBuf<0x100> aBuf;
       
   201 	aBuf.AppendFormatList(aFmt,list);
       
   202 	TInt r=aConsole.Write(aBuf);
       
   203 	__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Write-Console"),0));
       
   204 	}
       
   205 */