os/kernelhwsrv/kerneltest/f32test/fsstress/remwins.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/fsstress/remwins.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,167 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32test\fsstress\remwins.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#if defined(_UNICODE)
    1.22 +#if !defined(UNICODE)
    1.23 +#define UNICODE
    1.24 +#endif
    1.25 +#endif
    1.26 +
    1.27 +/*
    1.28 +#define WIN32_LEAN_AND_MEAN
    1.29 +#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
    1.30 +#include <windows.h>
    1.31 +#pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union
    1.32 +#include <stdlib.h>
    1.33 +*/
    1.34 +
    1.35 +#include <f32file.h>
    1.36 +#include <f32fsys.h>
    1.37 +#include <f32ver.h>
    1.38 +
    1.39 +#include "t_remfsy.h"
    1.40 +
    1.41 +
    1.42 +/*
    1.43 +#error Following code assumes %EPOCROOT% == '\\'
    1.44 +#if (defined(_DEBUG) && defined(_UNICODE))
    1.45 +GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\UDEB\\Z");
    1.46 +#elif defined(_DEBUG)
    1.47 +GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\DEB\\Z");
    1.48 +#elif defined(_UNICODE)
    1.49 +GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\UREL\\Z");
    1.50 +#else
    1.51 +GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\REL\\Z");
    1.52 +#endif
    1.53 +*/
    1.54 +
    1.55 +
    1.56 +GLDEF_C TBool GetEnvValue(TInt /*aDrive*/,TDes& /*aDes*/)
    1.57 +//
    1.58 +// Return a pointer to the value of the environment variable selected by aDrive
    1.59 +//
    1.60 +	{
    1.61 +	return(ETrue);
    1.62 +	}
    1.63 +
    1.64 +GLDEF_C TBool MapDrive(TDes& aFileName,TInt aDrive)
    1.65 +//
    1.66 +// Map aDrive to a path given by environment variables
    1.67 +//
    1.68 +	{
    1.69 +	TFileName aName;
    1.70 +//	TBuf<16> dumName=_L("Dum.txt");
    1.71 +//	TText* dumPtr;
    1.72 +///	GetFullPathName((_STRC)dumName.PtrZ(),aName.MaxLength(),(_STR)aName.Ptr(),(_STR*)&dumPtr);
    1.73 +	aName.SetLength(aName.MaxLength());
    1.74 +	aFileName=_L("?:");
    1.75 +	aFileName[0]=aName[0];
    1.76 +//
    1.77 +//	TFileName envValue;
    1.78 +//	if (GetEnvValue(aDrive,envValue))
    1.79 +//		{
    1.80 +//		if (envValue.Length()<=0 || envValue[0]!='\\')
    1.81 +//			aFileName=envValue;
    1.82 +//		else
    1.83 +//			aFileName+=envValue;
    1.84 +//		return(ETrue);
    1.85 +//		}
    1.86 +//
    1.87 +    //switch (aDrive)
    1.88 +	//	{
    1.89 +//	case EDriveC:
    1.90 +//#error Following code assumes %EPOCROOT% == '\\'
    1.91 +//		aFileName+=_L("\\EPOC32\\WINS\\C");
    1.92 +//		return(ETrue);
    1.93 +//	case EDriveZ:
    1.94 +//		aFileName+=ZPath;
    1.95 +//		return(ETrue);
    1.96 +	//default:
    1.97 +
    1.98 +	TChar drive;
    1.99 +	RFs::DriveToChar(aDrive,drive);
   1.100 +	aFileName=_L("?:");
   1.101 +	aFileName[0]=(TUint8)drive;
   1.102 +//	break;
   1.103 +//		}
   1.104 +	
   1.105 +	return(EFalse);
   1.106 +	}
   1.107 +
   1.108 +GLDEF_C TBool MapDriveInfo(TDriveInfo& anInfo,TInt aDrive)
   1.109 +//
   1.110 +// Get Fake drive info.
   1.111 +//
   1.112 +	{
   1.113 +
   1.114 +	if (aDrive==EDriveZ)
   1.115 +		{
   1.116 +		anInfo.iType=EMediaRom;
   1.117 +		anInfo.iMediaAtt=KMediaAttWriteProtected;
   1.118 +		return(ETrue);
   1.119 +		}
   1.120 +	if (aDrive==EDriveC)
   1.121 +		{
   1.122 +		anInfo.iType=EMediaHardDisk;
   1.123 +		anInfo.iMediaAtt=KMediaAttVariableSize|KMediaAttFormattable;
   1.124 +		return(ETrue);
   1.125 +		}
   1.126 +	TFileName envValue;
   1.127 +	if (GetEnvValue(aDrive,envValue))
   1.128 +		{
   1.129 +		anInfo.iType=EMediaRemote;
   1.130 +		anInfo.iMediaAtt=0;
   1.131 +		return(ETrue);		
   1.132 +		}
   1.133 +	return(EFalse);
   1.134 +	}
   1.135 +
   1.136 +GLDEF_C TBool MapDriveAttributes(TUint& aDriveAtt,TInt aDrive)
   1.137 +//
   1.138 +// Get Fake drive attributes.
   1.139 +//
   1.140 +	{
   1.141 +	if (aDrive==EDriveZ)
   1.142 +		{
   1.143 +		aDriveAtt=KDriveAttRom|KDriveAttInternal;
   1.144 +		return(ETrue);
   1.145 +		}
   1.146 +	if (aDrive==EDriveC)
   1.147 +		{
   1.148 +		aDriveAtt=KDriveAttRemovable|KDriveAttInternal;
   1.149 +		return(ETrue);
   1.150 +		}
   1.151 +	TFileName envValue;
   1.152 +	if (GetEnvValue(aDrive,envValue))
   1.153 +		{
   1.154 +		aDriveAtt=KDriveAttRemote;
   1.155 +		return(ETrue);		
   1.156 +		}
   1.157 +	return(EFalse);
   1.158 +	}
   1.159 +
   1.160 +
   1.161 +GLDEF_C void CheckAppendL(TDes& aTarget,const TDesC& aSrc)
   1.162 +//
   1.163 +// Leaves KErrBadName if aSrc cannot be appended to aTarget
   1.164 +//
   1.165 +	{
   1.166 +
   1.167 +	if (aTarget.MaxLength()<=aTarget.Length()+aSrc.Length())
   1.168 +		User::Leave(KErrBadName);
   1.169 +	}
   1.170 +