コード例 #1
0
/** 
Set the cluster count to a value greater than it should be
The bad cluster count is caluclated as 10000 added to the actual
cluster count value. The bad cluster count is then written to the disk 
in place of the actual cluster count. 

@param aClusterCount The cluster count of the volume
@param aPos The position at which to start writing to the raw disk

@return KErrNone if successful
*/	
TInt CBaseTestFat32Calculate::SetToGreater(TUint32 aClusterCount, TInt aPos)
	{
	TUint32 badClusterCount;
	badClusterCount = aClusterCount+10000;
	TUint8 num[4];
	TInt i;
	TInt r;

	r = TheDisk.Open(iTheFs, CurrentDrive());
	for (i=0; i<4; i++)
		{

		num[i] = 0;
		num[i] = num[i] + badClusterCount;
		badClusterCount = badClusterCount >> 8;
		}

	TUint8 data[1];
	TPtr8 buffer((TUint8*)&data[0],1);
	
	for (i=0; i<4; i++)
		{
		aPos = aPos + 1;
		r=TheDisk.Read(aPos,buffer);
		data[0]=num[i];
		r=TheDisk.Write(aPos,buffer);
		}
	TheDisk.Close();
	return r;
	}