kerneltest/f32test/fsstress/remwins.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\remwins.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 
       
    32 #include <f32file.h>
       
    33 #include <f32fsys.h>
       
    34 #include <f32ver.h>
       
    35 
       
    36 #include "t_remfsy.h"
       
    37 
       
    38 
       
    39 /*
       
    40 #error Following code assumes %EPOCROOT% == '\\'
       
    41 #if (defined(_DEBUG) && defined(_UNICODE))
       
    42 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\UDEB\\Z");
       
    43 #elif defined(_DEBUG)
       
    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");
       
    47 #else
       
    48 GLDEF_D const TFileName ZPath=_L("\\EPOC32\\RELEASE\\WINS\\REL\\Z");
       
    49 #endif
       
    50 */
       
    51 
       
    52 
       
    53 GLDEF_C TBool GetEnvValue(TInt /*aDrive*/,TDes& /*aDes*/)
       
    54 //
       
    55 // Return a pointer to the value of the environment variable selected by aDrive
       
    56 //
       
    57 	{
       
    58 	return(ETrue);
       
    59 	}
       
    60 
       
    61 GLDEF_C TBool MapDrive(TDes& aFileName,TInt aDrive)
       
    62 //
       
    63 // Map aDrive to a path given by environment variables
       
    64 //
       
    65 	{
       
    66 	TFileName aName;
       
    67 //	TBuf<16> dumName=_L("Dum.txt");
       
    68 //	TText* dumPtr;
       
    69 ///	GetFullPathName((_STRC)dumName.PtrZ(),aName.MaxLength(),(_STR)aName.Ptr(),(_STR*)&dumPtr);
       
    70 	aName.SetLength(aName.MaxLength());
       
    71 	aFileName=_L("?:");
       
    72 	aFileName[0]=aName[0];
       
    73 //
       
    74 //	TFileName envValue;
       
    75 //	if (GetEnvValue(aDrive,envValue))
       
    76 //		{
       
    77 //		if (envValue.Length()<=0 || envValue[0]!='\\')
       
    78 //			aFileName=envValue;
       
    79 //		else
       
    80 //			aFileName+=envValue;
       
    81 //		return(ETrue);
       
    82 //		}
       
    83 //
       
    84     //switch (aDrive)
       
    85 	//	{
       
    86 //	case EDriveC:
       
    87 //#error Following code assumes %EPOCROOT% == '\\'
       
    88 //		aFileName+=_L("\\EPOC32\\WINS\\C");
       
    89 //		return(ETrue);
       
    90 //	case EDriveZ:
       
    91 //		aFileName+=ZPath;
       
    92 //		return(ETrue);
       
    93 	//default:
       
    94 
       
    95 	TChar drive;
       
    96 	RFs::DriveToChar(aDrive,drive);
       
    97 	aFileName=_L("?:");
       
    98 	aFileName[0]=(TUint8)drive;
       
    99 //	break;
       
   100 //		}
       
   101 	
       
   102 	return(EFalse);
       
   103 	}
       
   104 
       
   105 GLDEF_C TBool MapDriveInfo(TDriveInfo& anInfo,TInt aDrive)
       
   106 //
       
   107 // Get Fake drive info.
       
   108 //
       
   109 	{
       
   110 
       
   111 	if (aDrive==EDriveZ)
       
   112 		{
       
   113 		anInfo.iType=EMediaRom;
       
   114 		anInfo.iMediaAtt=KMediaAttWriteProtected;
       
   115 		return(ETrue);
       
   116 		}
       
   117 	if (aDrive==EDriveC)
       
   118 		{
       
   119 		anInfo.iType=EMediaHardDisk;
       
   120 		anInfo.iMediaAtt=KMediaAttVariableSize|KMediaAttFormattable;
       
   121 		return(ETrue);
       
   122 		}
       
   123 	TFileName envValue;
       
   124 	if (GetEnvValue(aDrive,envValue))
       
   125 		{
       
   126 		anInfo.iType=EMediaRemote;
       
   127 		anInfo.iMediaAtt=0;
       
   128 		return(ETrue);		
       
   129 		}
       
   130 	return(EFalse);
       
   131 	}
       
   132 
       
   133 GLDEF_C TBool MapDriveAttributes(TUint& aDriveAtt,TInt aDrive)
       
   134 //
       
   135 // Get Fake drive attributes.
       
   136 //
       
   137 	{
       
   138 	if (aDrive==EDriveZ)
       
   139 		{
       
   140 		aDriveAtt=KDriveAttRom|KDriveAttInternal;
       
   141 		return(ETrue);
       
   142 		}
       
   143 	if (aDrive==EDriveC)
       
   144 		{
       
   145 		aDriveAtt=KDriveAttRemovable|KDriveAttInternal;
       
   146 		return(ETrue);
       
   147 		}
       
   148 	TFileName envValue;
       
   149 	if (GetEnvValue(aDrive,envValue))
       
   150 		{
       
   151 		aDriveAtt=KDriveAttRemote;
       
   152 		return(ETrue);		
       
   153 		}
       
   154 	return(EFalse);
       
   155 	}
       
   156 
       
   157 
       
   158 GLDEF_C void CheckAppendL(TDes& aTarget,const TDesC& aSrc)
       
   159 //
       
   160 // Leaves KErrBadName if aSrc cannot be appended to aTarget
       
   161 //
       
   162 	{
       
   163 
       
   164 	if (aTarget.MaxLength()<=aTarget.Length()+aSrc.Length())
       
   165 		User::Leave(KErrBadName);
       
   166 	}
       
   167