First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\fsstress\remwins.cpp
25 #define WIN32_LEAN_AND_MEAN
26 #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
28 #pragma warning( default : 4201 ) // nonstandard extension used : nameless struct/union
40 #error Following code assumes %EPOCROOT% == '\\'
41 #if (defined(_DEBUG) && defined(_UNICODE))
42 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\UDEB\\Z");
44 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\DEB\\Z");
45 #elif defined(_UNICODE)
46 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\UREL\\Z");
48 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\REL\\Z");
53 GLDEF_C TBool GetEnvValue(TInt /*aDrive*/,TDes& /*aDes*/)
55 // Return a pointer to the value of the environment variable selected by aDrive
61 GLDEF_C TBool MapDrive(TDes& aFileName,TInt aDrive)
63 // Map aDrive to a path given by environment variables
67 // TBuf<16> dumName=_L("Dum.txt");
69 /// GetFullPathName((_STRC)dumName.PtrZ(),aName.MaxLength(),(_STR)aName.Ptr(),(_STR*)&dumPtr);
70 aName.SetLength(aName.MaxLength());
72 aFileName[0]=aName[0];
74 // TFileName envValue;
75 // if (GetEnvValue(aDrive,envValue))
77 // if (envValue.Length()<=0 || envValue[0]!='\\')
78 // aFileName=envValue;
80 // aFileName+=envValue;
87 //#error Following code assumes %EPOCROOT% == '\\'
88 // aFileName+=_L("\\EPOC32\\WINS\\C");
96 RFs::DriveToChar(aDrive,drive);
98 aFileName[0]=(TUint8)drive;
105 GLDEF_C TBool MapDriveInfo(TDriveInfo& anInfo,TInt aDrive)
107 // Get Fake drive info.
113 anInfo.iType=EMediaRom;
114 anInfo.iMediaAtt=KMediaAttWriteProtected;
119 anInfo.iType=EMediaHardDisk;
120 anInfo.iMediaAtt=KMediaAttVariableSize|KMediaAttFormattable;
124 if (GetEnvValue(aDrive,envValue))
126 anInfo.iType=EMediaRemote;
133 GLDEF_C TBool MapDriveAttributes(TUint& aDriveAtt,TInt aDrive)
135 // Get Fake drive attributes.
140 aDriveAtt=KDriveAttRom|KDriveAttInternal;
145 aDriveAtt=KDriveAttRemovable|KDriveAttInternal;
149 if (GetEnvValue(aDrive,envValue))
151 aDriveAtt=KDriveAttRemote;
158 GLDEF_C void CheckAppendL(TDes& aTarget,const TDesC& aSrc)
160 // Leaves KErrBadName if aSrc cannot be appended to aTarget
164 if (aTarget.MaxLength()<=aTarget.Length()+aSrc.Length())
165 User::Leave(KErrBadName);