//存档 void TPlayerInfo::WriterPlayerInfo() { RFs oFs; if (oFs.Connect()) { return; }; RFileWriteStream oWriteStream; if (oWriteStream.Replace(oFs, *iFileName, EFileWrite)) { oFs.Close(); return; }; oWriteStream.PushL(); TInt32 playerCount = AWARD_PLAYER_COUNT; oWriteStream << playerCount; for (TInt i = 0; i < playerCount; i++) { if (i < AWARD_PLAYER_COUNT) { //iPlayerArray[i].ExternalizeL(oWriteStream); iPlayerList[i]->ExternalizeL(oWriteStream); } } oWriteStream.CommitL(); oWriteStream.Pop(); oWriteStream.Release(); oFs.Close(); }
void CMtfTestActionSaveMsvIdParamToFile::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSaveMsvIdParamToFile); TMsvId messageId = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0) ); HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL( fs ); TInt err = fs.MkDir( *paramFilePath ); if ( ! ( (err == KErrNone ) || ( err == KErrAlreadyExists ) ) ) { User::LeaveIfError( err ); } // else dir created successfully or already created. RFileWriteStream rf; err = rf.Open( fs , *paramFilePath , EFileWrite ); if ( err == KErrNotFound ) { err = rf.Create( fs, *paramFilePath , EFileWrite ); } User::LeaveIfError(err); rf.PushL(); // Writes may leave. rf << messageId; rf.CommitL(); rf.Pop(); rf.Release(); CleanupStack::PopAndDestroy(); // fs TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSaveMsvIdParamToFile); TestCase().ActionCompletedL(*this); }