persistentstorage/dbms/tdbms/t_dbperf2.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
  1290 
  1290 
  1291 void PrintDiskUsage(const TDesC& aPath, TInt aOffset = 0)
  1291 void PrintDiskUsage(const TDesC& aPath, TInt aOffset = 0)
  1292 	{
  1292 	{
  1293 	_LIT(KSpace, " ");
  1293 	_LIT(KSpace, " ");
  1294 	TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath);
  1294 	TheTest.Printf(_L("%*.*S%S\r\n"), aOffset, aOffset, &KSpace, &aPath);
  1295 	TFindFile* findFile = new TFindFile(TheFs);//TFindFile has TParse data member. 
  1295 	TFindFile findFile(TheFs);
  1296 											   //Since this function is called recoursively, on some platforms
       
  1297 											   //the test might crash - "stack overflow" problem.
       
  1298 	TEST(findFile != NULL);
       
  1299 	CDir* fileNameCol = NULL;
  1296 	CDir* fileNameCol = NULL;
  1300 	TBuf<8> fileNameMask;
  1297 	TBuf<8> fileNameMask;
  1301 	fileNameMask.Copy(_L("*.*"));
  1298 	fileNameMask.Copy(_L("*.*"));
  1302 	TInt err = findFile->FindWildByDir(fileNameMask, aPath, fileNameCol);
  1299 	TInt err = findFile.FindWildByDir(fileNameMask, aPath, fileNameCol);
  1303 	if(err == KErrNone)
  1300 	if(err == KErrNone)
  1304 		{
  1301 		{
  1305 		do
  1302 		do
  1306 			{
  1303 			{
  1307 			const TDesC& file = findFile->File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
  1304 			const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
  1308 			(void)TheParse.Set(file, NULL, NULL);
  1305 			(void)TheParse.Set(file, NULL, NULL);
  1309 			TPtrC driveName = TheParse.Drive();
  1306 			TPtrC driveName = TheParse.Drive();
  1310 			if(aPath.FindF(driveName) >= 0)
  1307 			if(aPath.FindF(driveName) < 0)
  1311 				{		
  1308 				{
  1312                 TInt cnt = fileNameCol->Count();
  1309 				goto cont;
  1313                 for(TInt i=0;i<cnt;++i)
  1310 				}
  1314                     {
       
  1315                     const ::TEntry& entry = (*fileNameCol)[i];
       
  1316                     if(!entry.IsDir())
       
  1317                         {
       
  1318                         TheTest.Printf(_L("%*.*S    %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize);
       
  1319                         }
       
  1320                     else
       
  1321                         {
       
  1322 						TFileName* path = new TFileName;//allocated in heap to prevent "stack overflow" prolem
       
  1323 						TEST(path != NULL);
       
  1324 						path->Copy(aPath);
       
  1325 						path->Append(entry.iName);
       
  1326 						path->Append(_L("\\"));
       
  1327                         PrintDiskUsage(*path, aOffset + 4);
       
  1328                         delete path;
       
  1329                         }
       
  1330                     }
       
  1331 				} // if(aPath.FindF(driveName) >= 0)
       
  1332 			
  1311 			
       
  1312 			TInt cnt = fileNameCol->Count();
       
  1313 			for(TInt i=0;i<cnt;++i)
       
  1314 				{
       
  1315 				const ::TEntry& entry = (*fileNameCol)[i];
       
  1316 				if(!entry.IsDir())
       
  1317 					{
       
  1318 					TheTest.Printf(_L("%*.*S    %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize);
       
  1319 					}
       
  1320 				else
       
  1321 					{
       
  1322 					TBuf<100> path;
       
  1323 					path.Copy(aPath);
       
  1324 					path.Append(entry.iName);
       
  1325 					path.Append(_L("\\"));
       
  1326 					PrintDiskUsage(path, aOffset + 4);
       
  1327 					}
       
  1328 				}
       
  1329 cont:			
  1333 			delete fileNameCol;
  1330 			delete fileNameCol;
  1334 			fileNameCol = NULL;
  1331 			fileNameCol = NULL;
  1335 			} while((err = findFile->FindWild(fileNameCol)) == KErrNone);//Get the next set of files
  1332 			} while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files
  1336 		}
  1333 		}
  1337 	else
  1334 	else
  1338 		{
  1335 		{
  1339 		TheTest.Printf(_L("  FindWildByDir() failed with err=%d\r\n"), err);
  1336 		TheTest.Printf(_L("  FindWildByDir() failed with err=%d\r\n"), err);
  1340 		}
  1337 		}
  1341 	delete findFile;
       
  1342 	}
  1338 	}
  1343 
  1339 
  1344 void DoTestL()
  1340 void DoTestL()
  1345 	{
  1341 	{
  1346 	GetFastCounterFrequency();
  1342 	GetFastCounterFrequency();
  1403 	TRAP(err, DoTestL());
  1399 	TRAP(err, DoTestL());
  1404 	DeleteFile(TheDatabaseFileName);
  1400 	DeleteFile(TheDatabaseFileName);
  1405 	DeleteFile(TheTestFileName);
  1401 	DeleteFile(TheTestFileName);
  1406 	TEST2(err, KErrNone);
  1402 	TEST2(err, KErrNone);
  1407 
  1403 
  1408 	TheTest.Printf(_L("====================== Disk usage ==================\r\n"));
  1404 	TheTest.Printf(_L("====================================================\r\n"));
  1409 	PrintDiskUsage(_L("c:\\"));
  1405 	PrintDiskUsage(_L("c:\\"));
  1410 	TheTest.Printf(_L("====================================================\r\n"));
  1406 	TheTest.Printf(_L("====================================================\r\n"));
  1411 	
  1407 	
  1412 	CloseAll();
  1408 	CloseAll();
  1413 
  1409