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