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