emailservices/emailstore/message_store/MsgStoreRfsPlugin/src/RfsMsgStorePlugin.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
equal deleted inserted replaced
8:e1b6206813b4 10:f5907b1a1053
    53 void CRfsMsgStorePlugin::RestoreFactorySettingsL( const TRfsReason aType )
    53 void CRfsMsgStorePlugin::RestoreFactorySettingsL( const TRfsReason aType )
    54     {
    54     {
    55     if ( aType == ENormalRfs || aType == EDeepRfs || aType == EInitRfs )
    55     if ( aType == ENormalRfs || aType == EDeepRfs || aType == EInitRfs )
    56         {
    56         {
    57         TUint driveStatus( 0 );
    57         TUint driveStatus( 0 );
    58 				TDriveNumber drive( EDriveC );
    58         TDriveNumber drive( EDriveC );
    59      		GetDriveL( drive );
    59         
    60         if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
    60         if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
    61             {
    61             {
    62             _LIT( KPrivate, ":\\Private\\" );    
    62             _LIT( KPrivate, ":\\Private\\" );    
    63             TChar driveChar;
    63             TChar driveChar;
    64             RFs::DriveToChar(drive, driveChar);
    64             RFs::DriveToChar(drive, driveChar);
    68             msgStorePath.Append(driveLetter);
    68             msgStorePath.Append(driveLetter);
    69             msgStorePath.Append(KPrivate);                
    69             msgStorePath.Append(KPrivate);                
    70             msgStorePath.AppendNum( KUidMessageStoreExe, EHex );
    70             msgStorePath.AppendNum( KUidMessageStoreExe, EHex );
    71             msgStorePath.Append( KPathDelimiter );
    71             msgStorePath.Append( KPathDelimiter );
    72             CFileMan* fileManager = CFileMan::NewL( iFs );
    72             CFileMan* fileManager = CFileMan::NewL( iFs );
    73             // this will recursively delete all files in all directories under the msgStorePath
    73             fileManager->RmDir( msgStorePath );
    74             // but directories under the msgStorePath are not deleted
       
    75             fileManager->Delete( msgStorePath, CFileMan::ERecurse );
       
    76             delete fileManager;
    74             delete fileManager;
    77             }
    75             }
    78         }
    76         }
    79     }
    77     }
    80 
    78 
   114 void CRfsMsgStorePlugin::ConstructL()
   112 void CRfsMsgStorePlugin::ConstructL()
   115     {
   113     {
   116     User::LeaveIfError( iFs.Connect() );
   114     User::LeaveIfError( iFs.Connect() );
   117     }
   115     }
   118     
   116     
   119 // -----------------------------------------------------------------------------
       
   120 // CRfsMsgStorePlugin::GetDriveL(TDriveNumber&)
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TInt CRfsMsgStorePlugin::GetDriveL( TDriveNumber& aDrive )
       
   124     {
       
   125     _LIT16( KDriveToUseFile, "db_drive.cfg" );
       
   126     TInt ret( KErrNotFound );
       
   127     RFs fs;
       
   128     if( fs.Connect() == KErrNone )
       
   129         {
       
   130         CleanupClosePushL( fs );               //+fs
       
   131         TFileName fileName;
       
   132         _LIT( KCDrive, "C:" );
       
   133         _LIT( KPrivate, "Private" );   
       
   134         fileName.Append(KCDrive());
       
   135         fileName.Append( KPathDelimiter ); 
       
   136         fileName.Append(KPrivate);
       
   137         fileName.Append( KPathDelimiter );                 
       
   138         fileName.AppendNum( KUidMessageStoreExe, EHex );
       
   139         fileName.Append( KPathDelimiter );        
       
   140         fileName.Append( KDriveToUseFile );
       
   141         if( BaflUtils::FileExists( fs, fileName ) )
       
   142             {
       
   143             RFileReadStream reader;
       
   144             if ( reader.Open( fs, fileName, EFileRead ) == KErrNone )
       
   145           		{
       
   146            		CleanupClosePushL( reader );             //+reader
       
   147            		TUint drive = reader.ReadUint32L();
       
   148               CleanupStack::PopAndDestroy( &reader );  //-reader
       
   149               if(drive <=EDriveZ)
       
   150 	              {
       
   151 	           		aDrive = static_cast<TDriveNumber>( drive );
       
   152            			ret = KErrNone;
       
   153            			}
       
   154            		}
       
   155             }
       
   156         CleanupStack::PopAndDestroy( &fs );    //-fs
       
   157         } // end if
       
   158     return ret;
       
   159     }
       
   160 
   117 
   161 // END FILE RfsMsgStorePlugin.cpp
   118 // END FILE RfsMsgStorePlugin.cpp