devencdiskutils/DevEncCommonUtils/src/DevEncDiskUtils.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
   253     TInt64 memoryCriticalSpace(0);
   253     TInt64 memoryCriticalSpace(0);
   254     TRAP(err, memoryCriticalSpace = FindCriticalLevelTresholdL());
   254     TRAP(err, memoryCriticalSpace = FindCriticalLevelTresholdL());
   255     if (!err)
   255     if (!err)
   256         return err;
   256         return err;
   257     TInt64 memoryWarningSpace(0);
   257     TInt64 memoryWarningSpace(0);
   258     TRAP(err, memoryWarningSpace = FindWarningLevelTresholdL());
   258     TRAP(err, memoryWarningSpace = FindWarningLevelTresholdL( aNumber ));
   259     if (!err)
   259     if (!err)
   260         return err;
   260         return err;
   261     
   261     
   262     DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryCriticalSpace = %d", (TInt) memoryCriticalSpace );
   262     DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryCriticalSpace = %d", (TInt) memoryCriticalSpace );
   263     DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryWarningSpace = %d", (TInt) memoryWarningSpace );
   263     DFLOG2( "CDevEncDiskUtils::DiskFinalize => memoryWarningSpace = %d", (TInt) memoryWarningSpace );
   264     
   264     
   265     //create the number of files needed to fill the mmc free space
   265     //create the number of files needed to fill the mmc or phone memory free space
   266     while( freeSpace )
   266     while( freeSpace )
   267         {
   267         {
   268         /* The real warning space is a percentage of the free space */
   268         TInt64 newMemoryWarningSpace(0);
   269         TInt64 newMemoryWarningSpace = ( TInt64 ) ( volumeInfo.iSize*( 100 - memoryWarningSpace ) ) / 100;
   269         if( aNumber == EDriveC )
       
   270         	{
       
   271             // The real warning space is a percentage of the free space. This applies only on drive C. 
       
   272             newMemoryWarningSpace = ( TInt64 ) ( volumeInfo.iSize*( 100 - memoryWarningSpace ) ) / 100;
       
   273         	}
       
   274         
   270         DFLOG2( "CDevEncDiskUtils::DiskFinalize => newMemoryWarningSpace = %d", (TInt) newMemoryWarningSpace );
   275         DFLOG2( "CDevEncDiskUtils::DiskFinalize => newMemoryWarningSpace = %d", (TInt) newMemoryWarningSpace );
   271 
   276 
   272         if( TInt64( volumeInfo.iFree ) > TInt64( KMaxInt ) )
   277         if( TInt64( volumeInfo.iFree ) > TInt64( KMaxInt ) )
   273         	{
   278         	{
   274             size = KMaxInt;
   279             size = KMaxInt;
   275             }
   280             }
   276         else
   281         else
   277         	{
   282         	{
   278         	size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - newMemoryWarningSpace );
   283             if( aNumber == EDriveC )
       
   284                 {
       
   285         	    size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - newMemoryWarningSpace );
       
   286                 }
       
   287             else
       
   288                 {
       
   289                 size = Max( 0LL, TInt64( volumeInfo.iFree ) - memoryCriticalSpace - memoryWarningSpace );
       
   290                 }
   279         	}
   291         	}
   280 
   292 
   281         TFileName temp;
   293         TFileName temp;
   282         RFile file;
   294         RFile file;
   283 
   295 
   300 
   312 
   301         err = fs.Volume( volumeInfo, aNumber );
   313         err = fs.Volume( volumeInfo, aNumber );
   302         if( err )
   314         if( err )
   303             DFLOG2( "..fs.Volume fail %d", err );    
   315             DFLOG2( "..fs.Volume fail %d", err );    
   304 
   316 
   305         if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + newMemoryWarningSpace )
   317         if( aNumber == EDriveC )
   306         	{
   318         	{
   307             freeSpace = EFalse;
   319             if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + newMemoryWarningSpace )
       
   320         	    {
       
   321                 freeSpace = EFalse;
       
   322                 }
       
   323             }
       
   324         else
       
   325             {
       
   326             if( TInt64( volumeInfo.iFree ) <= memoryCriticalSpace + memoryWarningSpace )
       
   327                 {
       
   328                 freeSpace = EFalse;
       
   329                 }
   308             }
   330             }
   309         }
   331         }
   310 
   332 
   311     //delete the created files
   333     //delete the created files
   312     for( TInt i=0;i < files.Count();i++ )
   334     for( TInt i=0;i < files.Count();i++ )
   346 
   368 
   347 // --------------------------------------------------------------------------
   369 // --------------------------------------------------------------------------
   348 // CDevEncDiskUtils::FindWarningLevelTresholdL()
   370 // CDevEncDiskUtils::FindWarningLevelTresholdL()
   349 // 
   371 // 
   350 // --------------------------------------------------------------------------
   372 // --------------------------------------------------------------------------
   351 TInt64 CDevEncDiskUtils::FindWarningLevelTresholdL()
   373 TInt64 CDevEncDiskUtils::FindWarningLevelTresholdL( const TDriveNumber aNumber )
   352 	{
   374 	{
   353 	return (TInt64) FindValueL( KCRUidUiklaf, /*KUikOODDiskWarningThreshold*/KUikOODDiskFreeSpaceWarningNoteLevel );
   375       if( aNumber == EDriveC )
       
   376           {
       
   377 	      return (TInt64) FindValueL( KCRUidUiklaf, KUikOODDiskFreeSpaceWarningNoteLevel );
       
   378           }
       
   379       else
       
   380           {
       
   381           return (TInt64) FindValueL( KCRUidUiklaf, KUikOODDiskFreeSpaceWarningNoteLevelMassMemory );
       
   382           }
   354 	}
   383 	}
   355 
   384 
   356 // End of file
   385 // End of file