kerneltest/f32test/fsstress/t_remmnt.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\t_remmnt.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 #include <f32file.h>
       
    32 #include <f32fsys.h>
       
    33 #include <f32ver.h>
       
    34 #include <e32twin.h>
       
    35 #include <e32uid.h>
       
    36 
       
    37 #include "t_remfsy.h"
       
    38 
       
    39 
       
    40 
       
    41 LOCAL_C TInt GetMediaSize(TInt /*aDriveNumber*/,TInt64& /*aSize*/,TInt64& /*aFree*/)
       
    42 //
       
    43 // Return the size and free space on a drive.
       
    44 //
       
    45 	{
       
    46 	return(KErrNone);
       
    47 	}
       
    48 
       
    49 LOCAL_C TInt GetVolume(TInt /*aDriveNumber*/,TDes& aName,TUint& aUniqueID)
       
    50 //
       
    51 // Return the volume name and uniqueID.
       
    52 //
       
    53 	{
       
    54 	aUniqueID=1234;
       
    55 	aName=(_L("REMOTDRV"));
       
    56 	return(KErrNone);	
       
    57 	}
       
    58 
       
    59 
       
    60 //////////////////////////////////////////////////////////////////////////
       
    61 //								CRemoteMountCB							//
       
    62 //////////////////////////////////////////////////////////////////////////	
       
    63 
       
    64 
       
    65 CRemoteMountCB::CRemoteMountCB()
       
    66 //
       
    67 // Constructor
       
    68 //
       
    69 	{
       
    70 	__DECLARE_NAME(_S("CRemoteMountCB"));
       
    71 	}
       
    72 
       
    73 CRemoteMountCB::~CRemoteMountCB()
       
    74 //
       
    75 // Destructor
       
    76 //
       
    77 	{}
       
    78 
       
    79 void CRemoteMountCB::MountL(TBool /*aForceMount*/)
       
    80 //
       
    81 // Mount a media. Only allowed to leave with KErrNoMemory,KErrNotReady,KErrCorrupt,KErrUnknown.
       
    82 //
       
    83 	{
       
    84 //	TInt64 s,f;
       
    85 	TFileName driveName;
       
    86 	TInt d=Drive().DriveNumber();
       
    87 //	TInt driveNum=d;
       
    88 	if (MapDrive(driveName,d))
       
    89 		RFs::CharToDrive(driveName[0],d);
       
    90 	//User::LeaveIfError(GetMediaSize(d,s,f));
       
    91 	//if (driveNum==EDriveZ)
       
    92 //		iSize=4*1048576;
       
    93 //	else
       
    94 		//iSize=s;
       
    95 	iSize=4*1024*16;
       
    96 	User::LeaveIfError(GetVolume(d,driveName,iUniqueID));
       
    97 	HBufC* pN=driveName.AllocL();
       
    98 	SetVolumeName(pN);
       
    99 	}
       
   100 
       
   101 TInt CRemoteMountCB::ReMount()
       
   102 //
       
   103 // Try and remount this media.
       
   104 //
       
   105 	{
       
   106 
       
   107 	TFileName n;
       
   108 	TInt d=Drive().DriveNumber();
       
   109 	if (MapDrive(n,d))
       
   110 		RFs::CharToDrive(n[0],d);
       
   111 	TUint uniqueID;
       
   112 	TInt r=GetVolume(d,n,uniqueID);
       
   113 	if (r!=KErrNone)
       
   114 		return(r);
       
   115 	if (n==VolumeName() && uniqueID==iUniqueID)
       
   116 		return(KErrNone);
       
   117 	return(KErrGeneral);
       
   118 	}
       
   119 
       
   120 void CRemoteMountCB::Dismounted()
       
   121 //
       
   122 //	Dummy implementation of a pure virtual function
       
   123 //
       
   124 	{}
       
   125 
       
   126 void CRemoteMountCB::VolumeL(TVolumeInfo& aVolume) const
       
   127 //
       
   128 // Return the volume info.
       
   129 //
       
   130 	{
       
   131 	TInt64 s,f(0);
       
   132 	TFileName n;
       
   133 	TInt d=Drive().DriveNumber();
       
   134 	TInt driveNum=d;
       
   135 	if (MapDrive(n,d))
       
   136 		RFs::CharToDrive(n[0],d);
       
   137 	User::LeaveIfError(GetMediaSize(d,s,f));
       
   138 	if (driveNum==EDriveZ)
       
   139 		aVolume.iFree=0;
       
   140 	else
       
   141 		aVolume.iFree=f;
       
   142 	}
       
   143 
       
   144 
       
   145 void CRemoteMountCB::SetVolumeL(TDes& /*aName*/)
       
   146 //
       
   147 //	Set the volume label
       
   148 //	Dummy implementation of a pure virtual function
       
   149 //
       
   150 	{}
       
   151 
       
   152 
       
   153 void CRemoteMountCB::IsFileInRom(const TDesC& /*aName*/,TUint8*& /*aFileStart*/)
       
   154 //
       
   155 // Return the address of the file if it is in rom
       
   156 //
       
   157 	{}
       
   158 
       
   159 
       
   160 
       
   161 
       
   162 void CRemoteMountCB::MkDirL(const TDesC& /*aName*/)
       
   163 //
       
   164 //	Make a directory
       
   165 //	Dummy implementation of a pure virtual function
       
   166 //
       
   167 	{
       
   168 	User::After(200000);	//	Wait 0.2 seconds
       
   169 	}
       
   170 
       
   171 
       
   172 void CRemoteMountCB::RmDirL(const TDesC& /*aName*/)
       
   173 //
       
   174 //	Remove a directory
       
   175 //	Dummy implementation of a pure virtual function
       
   176 //
       
   177 	{
       
   178 	User::After(200000);	//	Wait 0.2 seconds
       
   179 	}
       
   180 
       
   181 void CRemoteMountCB::DeleteL(const TDesC& /*aName*/)
       
   182 //
       
   183 //	Delete a file
       
   184 //	Dummy implementation of a pure virtual function
       
   185 //
       
   186 	{
       
   187 	User::After(200000);	//  Wait 0.2 seconds
       
   188 	}
       
   189 
       
   190 void CRemoteMountCB::RenameL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
       
   191 //
       
   192 //	Rename a file or directory
       
   193 //	Dummy implementation of a pure virtual function
       
   194 //
       
   195 	{
       
   196 	User::After(200000);	//  Wait 0.2 seconds
       
   197 	}
       
   198 
       
   199 void CRemoteMountCB::ReplaceL(const TDesC& /*anOldName*/,const TDesC& /*aNewName*/)
       
   200 //
       
   201 //	Delete aNewName if it exists and rename anOldName
       
   202 //	Dummy implementation of a pure virtual function
       
   203 //
       
   204 	{
       
   205 	User::After(200000);	//  Wait 0.2 seconds
       
   206 	}
       
   207 
       
   208 void CRemoteMountCB::ReadUidL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
       
   209 //
       
   210 //	Read the entry uid if present
       
   211 //
       
   212 	{
       
   213 	User::After(200000);	//  Wait 0.2 seconds
       
   214 	}
       
   215 
       
   216 
       
   217 void CRemoteMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
       
   218 //
       
   219 //	Get entry details
       
   220 //	Dummy implementation of a pure virtual function
       
   221 //
       
   222 	{
       
   223 	User::After(200000);	//  Wait 0.2 seconds
       
   224 	}
       
   225 
       
   226 void CRemoteMountCB::SetEntryL(const TDesC& /*aName*/,const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
       
   227 //
       
   228 //	Set entry details
       
   229 //	Dummy implementation of a pure virtual function
       
   230 //
       
   231 	{
       
   232 	User::After(200000);	//  Wait 0.2 seconds
       
   233 	}
       
   234 
       
   235 
       
   236 void CRemoteMountCB::FileOpenL(const TDesC& /*aName*/,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
       
   237 //
       
   238 //	Open a File
       
   239 //	Dummy implementation of a pure virtual function
       
   240 //
       
   241 	{
       
   242 	User::After(200000);	//  Wait 0.2 seconds
       
   243 	}
       
   244 
       
   245 void CRemoteMountCB::DirOpenL(const TDesC& /*aName*/,CDirCB* /*aDir*/)
       
   246 //
       
   247 //	Open a directory on the current mount
       
   248 //	Dummy implementation of a pure virtual function
       
   249 //
       
   250 	{
       
   251 	User::After(200000);	//  Wait 0.2 seconds
       
   252 	}
       
   253 
       
   254 
       
   255 void CRemoteMountCB::RawReadL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/) const
       
   256 //
       
   257 //	Read directly from disk
       
   258 //
       
   259 	{
       
   260 	User::Leave(KErrNotSupported);
       
   261 	}
       
   262 
       
   263 void CRemoteMountCB::RawWriteL(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*anOffset*/,const RMessagePtr2& /*aMessage*/)
       
   264 //
       
   265 //	Write directly to disk
       
   266 //
       
   267 	{
       
   268 	User::Leave(KErrNotSupported);
       
   269 	}
       
   270 
       
   271 void CRemoteMountCB::GetShortNameL(const TDesC& /*aLongName*/,TDes& /*aShortName*/)
       
   272 //
       
   273 //	Get the short name associated with aLongName
       
   274 //	Dummy implementation of a pure virtual function
       
   275 //
       
   276 	{}
       
   277 
       
   278 
       
   279 void CRemoteMountCB::GetLongNameL(const TDesC& /*aShortName*/,TDes& /*aLongName*/)
       
   280 //
       
   281 //	Get the short name associated with aLongName
       
   282 //	Dummy implementation of a pure virtual function
       
   283 //
       
   284 	{}
       
   285 
       
   286 
       
   287 void CRemoteMountCB::ReadSectionL(const TDesC& /*aName*/,TInt /*aPos*/,TAny* /*aTrg*/,TInt /*aLength*/,const RMessagePtr2& /*aMessage*/)
       
   288 //
       
   289 //	Get the short name associated with aLongName
       
   290 //	Dummy implementation of a pure virtual function
       
   291 //
       
   292 	{}
       
   293 
       
   294 
       
   295 
       
   296 TBool CRemoteMountCB::IsRomDrive() const
       
   297 //
       
   298 // Returns ETrue if the drive == EDriveZ
       
   299 //
       
   300 	{
       
   301 	return(Drive().DriveNumber()==EDriveZ);
       
   302 	}
       
   303 
       
   304 
       
   305