persistentstorage/dbms/tdbms/t_dbperf2.cpp
changeset 40 b8bdbc8f59c7
parent 17 55f2396f6d25
child 55 44f437012c90
equal deleted inserted replaced
33:5e4beccba4e9 40:b8bdbc8f59c7
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 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(TheFs);
  1295 	TFindFile* findFile = new TFindFile(TheFs);//TFindFile has TParse data member. 
       
  1296 											   //Since this function is called recoursively, on some platforms
       
  1297 											   //the test might crash - "stack overflow" problem.
       
  1298 	TEST(findFile != NULL);
  1296 	CDir* fileNameCol = NULL;
  1299 	CDir* fileNameCol = NULL;
  1297 	TBuf<8> fileNameMask;
  1300 	TBuf<8> fileNameMask;
  1298 	fileNameMask.Copy(_L("*.*"));
  1301 	fileNameMask.Copy(_L("*.*"));
  1299 	TInt err = findFile.FindWildByDir(fileNameMask, aPath, fileNameCol);
  1302 	TInt err = findFile->FindWildByDir(fileNameMask, aPath, fileNameCol);
  1300 	if(err == KErrNone)
  1303 	if(err == KErrNone)
  1301 		{
  1304 		{
  1302 		do
  1305 		do
  1303 			{
  1306 			{
  1304 			const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
  1307 			const TDesC& file = findFile->File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
  1305 			(void)TheParse.Set(file, NULL, NULL);
  1308 			(void)TheParse.Set(file, NULL, NULL);
  1306 			TPtrC driveName = TheParse.Drive();
  1309 			TPtrC driveName = TheParse.Drive();
  1307 			if(aPath.FindF(driveName) >= 0)
  1310 			if(aPath.FindF(driveName) >= 0)
  1308 				{		
  1311 				{		
  1309                 TInt cnt = fileNameCol->Count();
  1312                 TInt cnt = fileNameCol->Count();
  1314                         {
  1317                         {
  1315                         TheTest.Printf(_L("%*.*S    %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize);
  1318                         TheTest.Printf(_L("%*.*S    %S, size=%d\r\n"), aOffset, aOffset, &KSpace, &entry.iName, entry.iSize);
  1316                         }
  1319                         }
  1317                     else
  1320                     else
  1318                         {
  1321                         {
  1319                         TBuf<100> path;
  1322 						TFileName* path = new TFileName;//allocated in heap to prevent "stack overflow" prolem
  1320                         path.Copy(aPath);
  1323 						TEST(path != NULL);
  1321                         path.Append(entry.iName);
  1324 						path->Copy(aPath);
  1322                         path.Append(_L("\\"));
  1325 						path->Append(entry.iName);
  1323                         PrintDiskUsage(path, aOffset + 4);
  1326 						path->Append(_L("\\"));
       
  1327                         PrintDiskUsage(*path, aOffset + 4);
       
  1328                         delete path;
  1324                         }
  1329                         }
  1325                     }
  1330                     }
  1326 				} // if(aPath.FindF(driveName) >= 0)
  1331 				} // if(aPath.FindF(driveName) >= 0)
  1327 			
  1332 			
  1328 			delete fileNameCol;
  1333 			delete fileNameCol;
  1329 			fileNameCol = NULL;
  1334 			fileNameCol = NULL;
  1330 			} while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files
  1335 			} while((err = findFile->FindWild(fileNameCol)) == KErrNone);//Get the next set of files
  1331 		}
  1336 		}
  1332 	else
  1337 	else
  1333 		{
  1338 		{
  1334 		TheTest.Printf(_L("  FindWildByDir() failed with err=%d\r\n"), err);
  1339 		TheTest.Printf(_L("  FindWildByDir() failed with err=%d\r\n"), err);
  1335 		}
  1340 		}
       
  1341 	delete findFile;
  1336 	}
  1342 	}
  1337 
  1343 
  1338 void DoTestL()
  1344 void DoTestL()
  1339 	{
  1345 	{
  1340 	GetFastCounterFrequency();
  1346 	GetFastCounterFrequency();
  1397 	TRAP(err, DoTestL());
  1403 	TRAP(err, DoTestL());
  1398 	DeleteFile(TheDatabaseFileName);
  1404 	DeleteFile(TheDatabaseFileName);
  1399 	DeleteFile(TheTestFileName);
  1405 	DeleteFile(TheTestFileName);
  1400 	TEST2(err, KErrNone);
  1406 	TEST2(err, KErrNone);
  1401 
  1407 
  1402 	TheTest.Printf(_L("====================================================\r\n"));
  1408 	TheTest.Printf(_L("====================== Disk usage ==================\r\n"));
  1403 	PrintDiskUsage(_L("c:\\"));
  1409 	PrintDiskUsage(_L("c:\\"));
  1404 	TheTest.Printf(_L("====================================================\r\n"));
  1410 	TheTest.Printf(_L("====================================================\r\n"));
  1405 	
  1411 	
  1406 	CloseAll();
  1412 	CloseAll();
  1407 
  1413