918 // CFileManagerRemovableDriveHandler::StartFormatProcessL |
918 // CFileManagerRemovableDriveHandler::StartFormatProcessL |
919 // --------------------------------------------------------------------------- |
919 // --------------------------------------------------------------------------- |
920 // |
920 // |
921 void CFileManagerRemovableDriveHandler::StartFormatProcessL() |
921 void CFileManagerRemovableDriveHandler::StartFormatProcessL() |
922 { |
922 { |
923 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 1 "); |
|
924 // Store the current volume name over format operation. |
923 // Store the current volume name over format operation. |
925 TRAPD( err, StoreVolumeNameL( iDrive ) ); |
924 TRAPD( err, StoreVolumeNameL( iDrive ) ); |
926 LOG_IF_ERROR1( |
925 LOG_IF_ERROR1( |
927 err, |
926 err, |
928 "FileManagerRemovableDriveHandler::StartFormatProcessL-StoreVolumeName %d", |
927 "FileManagerRemovableDriveHandler::StartFormatProcessL-StoreVolumeName %d", |
929 err ); |
928 err ); |
930 |
|
931 TDriveName driveName( TDriveUnit( iDrive ).Name() ); |
929 TDriveName driveName( TDriveUnit( iDrive ).Name() ); |
932 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 2"); |
|
933 // Resolve drive character and open formatter |
930 // Resolve drive character and open formatter |
934 iFormatter.Close(); |
931 iFormatter.Close(); |
935 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 2.1"); |
|
936 err = iFormatter.Open( |
932 err = iFormatter.Open( |
937 iFs, driveName, EFullFormat, iFinalValue ); |
933 iFs, driveName, EFullFormat, iFinalValue ); |
938 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 2.2 RFormat::Open full err=%d", err); |
|
939 |
|
940 // Forced format for locked card |
934 // Forced format for locked card |
941 if ( err == KErrLocked ) |
935 if ( err == KErrLocked ) |
942 { |
936 { |
943 // Erase password and try again |
937 // Erase password and try again |
944 err = iFs.ErasePassword( iDrive ); |
938 err = iFs.ErasePassword( iDrive ); |
945 INFO_LOG1( "FileManagerRemovableDriveHandler::StartFormatProcessL-ErasePassword result=%d", err); |
|
946 |
|
947 if (err == KErrNone) |
939 if (err == KErrNone) |
948 { |
940 { |
949 err = iFormatter.Open(iFs, driveName, EFullFormat , iFinalValue ); |
941 err = iFormatter.Open(iFs, driveName, EFullFormat , iFinalValue ); |
950 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() RFormat::Open again err=%d", err); |
|
951 } |
942 } |
952 } |
943 } |
953 |
|
954 if (err == KErrInUse) |
944 if (err == KErrInUse) |
955 { |
945 { |
956 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL KErrInUse try force format err=%d", err); |
946 TBool reallyFormat = ETrue; |
957 |
|
958 // There are still files open on the drive being formatted, prompt the user to |
|
959 // ask if they want to format anyway. |
|
960 // |
|
961 // formatting. |
|
962 //TBool reallyFormat = FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(_L("There are files open on this drive, continue with format?")); |
|
963 TBool reallyFormat = ETrue; // TEMP! - should ask the user to confirm Yes / No |
|
964 |
|
965 if (reallyFormat) |
947 if (reallyFormat) |
966 { |
948 { |
967 // Open the RFormat sub-session with force format flags |
|
968 RDebug::Printf( "FileManagerRemovableDriveHandler::StartFormatProcessL-******force format*****"); |
|
969 err = iFormatter.Open( |
949 err = iFormatter.Open( |
970 iFs, driveName, EFullFormat | EForceFormat, iFinalValue ); |
950 iFs, driveName, EFullFormat | EForceFormat, iFinalValue ); |
971 RDebug::Printf( "FileManagerRemovableDriveHandler::StartFormatProcessL-******force format***** err = %d", err); |
|
972 } |
951 } |
973 } |
952 } |
974 |
|
975 // By the time we get here, one of three things could have happened: |
|
976 // 1. RFormat has been opened with standard full format flag with no error |
|
977 // 2. Some other app still has files opened so full format cannot be used. |
|
978 // A second attempt has been made to open the format sub-session with |
|
979 // full format flags and this has succeeded. |
|
980 // 3. As 2 but for some other reason (corrupt card perhaps?), force format |
|
981 // does not work in which case abort format. |
|
982 |
|
983 |
|
984 TFullName fsName; |
953 TFullName fsName; |
985 if (err == KErrNone) |
954 if (err == KErrNone) |
986 { |
955 { |
987 err = iFs.FileSystemName( fsName, iDrive ); |
956 err = iFs.FileSystemName( fsName, iDrive ); |
988 |
|
989 RDebug::Printf( "FileManagerRemovableDriveHandler::StartFormatProcessL-fsName=%S, result=%d", |
|
990 &fsName, err ); |
|
991 |
957 |
992 if ( err == KErrNone && fsName.Length() > 0 ) |
958 if ( err == KErrNone && fsName.Length() > 0 ) |
993 { |
959 { |
994 // Prevent SysAp shutting down applications |
960 // Prevent SysAp shutting down applications |
995 RProperty::Set( |
961 RProperty::Set( |
1010 |
976 |
1011 if ( iFinalValue && err == KErrNone ) |
977 if ( iFinalValue && err == KErrNone ) |
1012 { |
978 { |
1013 TRAP( err, InformStartL( iFinalValue ) ); |
979 TRAP( err, InformStartL( iFinalValue ) ); |
1014 if ( err == KErrNone ) |
980 if ( err == KErrNone ) |
1015 { |
981 { |
1016 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() RFormat::Next err = %d, tracks left=%d", err, iFinalValue); |
|
1017 iFormatCountBuf = iFinalValue; |
982 iFormatCountBuf = iFinalValue; |
1018 iFormatter.Next( iFormatCountBuf, iStatus ); |
983 iFormatter.Next( iFormatCountBuf, iStatus ); |
1019 SetActive(); |
984 SetActive(); |
1020 } |
985 } |
1021 } |
986 } |
1022 if ( !iFinalValue || err != KErrNone ) |
987 if ( !iFinalValue || err != KErrNone ) |
1023 { |
988 { |
1024 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 6 err = %d", err); |
989 EndFormatProcessL( err ); |
1025 EndFormatProcessL( err ); |
990 } |
1026 RDebug::Printf(">> CFileManagerRemovableDriveHandler::StartFormatProcessL() 7 err = %d", err); |
|
1027 } |
|
1028 RDebug::Printf("<< CFileManagerRemovableDriveHandler::StartFormatProcessL() 8 err=%d", err); |
|
1029 } |
991 } |
1030 // --------------------------------------------------------------------------- |
992 // --------------------------------------------------------------------------- |
1031 // CFileManagerRemovableDriveHandler::CloseAppsL |
993 // CFileManagerRemovableDriveHandler::CloseAppsL |
1032 // --------------------------------------------------------------------------- |
994 // --------------------------------------------------------------------------- |
1033 // |
995 // |