272 } |
272 } |
273 |
273 |
274 |
274 |
275 EXPORT_C TMemSpyPercentText MemSpyEngineUtils::FormatPercentage( TReal aOneHundredPercentValue, TReal aValue ) |
275 EXPORT_C TMemSpyPercentText MemSpyEngineUtils::FormatPercentage( TReal aOneHundredPercentValue, TReal aValue ) |
276 { |
276 { |
277 const TReal value = (( aValue / aOneHundredPercentValue) * 100.0); |
277 const TReal value = (TInt) (( aValue / aOneHundredPercentValue) * 100.0); |
278 |
278 |
279 _LIT(KPercentFormat, "%3.2f %%"); |
279 _LIT(KPercentFormat, "%3.2f %%"); |
280 |
280 |
281 TMemSpyPercentText val; |
281 TMemSpyPercentText val; |
282 val.Format( KPercentFormat, value ); |
282 val.Format( KPercentFormat, value ); |
363 |
363 |
364 |
364 |
365 EXPORT_C void MemSpyEngineUtils::GetFolderL( RFs& aFsSession, TDes& aFolder, const CMemSpyEngineSinkMetaData& aMetaData, const TDriveNumber* aForceDrive ) |
365 EXPORT_C void MemSpyEngineUtils::GetFolderL( RFs& aFsSession, TDes& aFolder, const CMemSpyEngineSinkMetaData& aMetaData, const TDriveNumber* aForceDrive ) |
366 { |
366 { |
367 const TChar KMemSpyDirectorySeparator = '\\'; |
367 const TChar KMemSpyDirectorySeparator = '\\'; |
368 const TChar KMemSpyDriveSeparator = ':'; |
|
369 |
368 |
370 TDriveList drives; |
369 TDriveList drives; |
371 User::LeaveIfError( aFsSession.DriveList( drives ) ); |
370 User::LeaveIfError( aFsSession.DriveList( drives ) ); |
372 |
371 |
373 // We prefer to log to MMC if its available. If not, we'll log to C: instead. On |
372 // We prefer to log to MMC if its available. If not, we'll log to C: instead. On |
378 logDrive = *aForceDrive; |
377 logDrive = *aForceDrive; |
379 TRACE( RDebug::Printf( "MemSpyEngineUtils::GetFolderL() - FORCED TO DRIVE: %c:\\", *aForceDrive + 'A' ) ); |
378 TRACE( RDebug::Printf( "MemSpyEngineUtils::GetFolderL() - FORCED TO DRIVE: %c:\\", *aForceDrive + 'A' ) ); |
380 } |
379 } |
381 else |
380 else |
382 { |
381 { |
383 // check if drive is specified in root path |
382 logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession ); |
384 if ( aMetaData.Root().Length() > 2 && aMetaData.Root()[1] == KMemSpyDriveSeparator ) |
|
385 { |
|
386 TChar drive = aMetaData.Root()[0]; |
|
387 |
|
388 // check if drive is valid |
|
389 if (drives.Locate(drive) != KErrNone) |
|
390 { |
|
391 TDriveUnit driveUnit( aMetaData.Root().Left(1) ); |
|
392 logDrive = static_cast<TDriveNumber>(static_cast<TInt>(driveUnit)); |
|
393 } |
|
394 else |
|
395 { |
|
396 logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession ); |
|
397 } |
|
398 } |
|
399 else |
|
400 { |
|
401 logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession ); |
|
402 } |
|
403 } |
383 } |
404 |
384 |
405 // Prepare the drive buffer |
385 // Prepare the drive buffer |
406 HBufC* fileName = HBufC::NewLC( KMaxFileName * 2 ); |
386 HBufC* fileName = HBufC::NewLC( KMaxFileName * 2 ); |
407 TPtr pFileName( fileName->Des() ); |
387 TPtr pFileName( fileName->Des() ); |
408 |
388 |
409 // Prepare the drive name |
389 // Prepare the drive name |
410 TDriveUnit driveUnit( logDrive ); |
390 TDriveUnit driveUnit( logDrive ); |
411 pFileName.Append( driveUnit.Name() ); |
391 pFileName.Append( driveUnit.Name() ); |
412 |
392 pFileName.Append( KMemSpyLogRootPath ); |
413 if ( aMetaData.Root().Length() == 0 ) |
|
414 { |
|
415 pFileName.Append( KMemSpyLogRootPath ); |
|
416 } |
|
417 else |
|
418 { |
|
419 TPtrC root( aMetaData.Root() ); |
|
420 // check if root path contains drive (e.g. c:) and remove it |
|
421 if ( root.Length() > 2 && root[1] == KMemSpyDriveSeparator ) |
|
422 { |
|
423 root.Set( root.Mid( 2 ) ); |
|
424 } |
|
425 // check if root starts with \ and remove it |
|
426 if ( root.Length() > 1 && root[0] == KMemSpyDirectorySeparator ) |
|
427 { |
|
428 root.Set( root.Mid( 1 ) ); |
|
429 } |
|
430 |
|
431 // append root path |
|
432 pFileName.Append( KMemSpyDirectorySeparator ); |
|
433 pFileName.Append( root ); |
|
434 |
|
435 // add trailing slash if necessary |
|
436 if ( root[root.Length() - 1] != KMemSpyDirectorySeparator ) |
|
437 { |
|
438 pFileName.Append( KMemSpyDirectorySeparator ); |
|
439 } |
|
440 } |
|
441 |
393 |
442 // Add any custom folder information |
394 // Add any custom folder information |
443 if ( aMetaData.Folder().Length() > 0 ) |
395 if ( aMetaData.Folder().Length() > 0 ) |
444 { |
396 { |
445 pFileName.Append( aMetaData.Folder() ); |
397 pFileName.Append( aMetaData.Folder() ); |