void CJavaDebugAgentSettings::SaveL(const TDesC& aPrefsFile) const { RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); RFileWriteStream out; out.PushL(); TInt err = out.Create(fs, aPrefsFile, EFileWrite); if (err != KErrNone) { // Try to eliminate the problem if we can switch (err) { case KErrAlreadyExists: fs.Delete(aPrefsFile); break; case KErrPathNotFound: fs.MkDirAll(aPrefsFile); break; default: User::Leave(err); break; } User::LeaveIfError(out.Create(fs, aPrefsFile, EFileWrite)); } SaveL(&out); out.Close(); out.Pop(); CleanupStack::PopAndDestroy(&fs); }
/** @fn void WriteIniFileL() Open the ini file and store the values */ LOCAL_C void WriteIniFileL() { RFs fileSession; User::LeaveIfError(fileSession.Connect()); CleanupClosePushL(fileSession); // create folder path fileSession.MkDirAll(IniFileName); RFileWriteStream fileWriteStream; User::LeaveIfError(fileWriteStream.Create(fileSession, IniFileName ,EFileWrite)); CleanupClosePushL(fileWriteStream); //write the KEComUid to the stream fileWriteStream.WriteInt32L(KEComUid); //write the KSsaUid to the stream fileWriteStream.WriteInt32L(KSsaUid); //write the SSA value to the stream fileWriteStream.WriteInt8L(KSsaDisabled); //commit changes to the stream fileWriteStream.CommitL(); // close: fileSession, fileWriteStream CleanupStack::PopAndDestroy(2); }
// ----------------------------------------------------------------------------- // CSisxUIStartupFile::WritePrivateStartupItemsL // Write startup items into private file. // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CSisxUIStartupFile::WritePrivateStartupItemsL( RArray<TStartupTaskParam>& aStartupItems ) { if ( PrivateFileExists() ) { iFileSession.Delete( *iPrivateFile ); } if ( aStartupItems.Count() > 0 ) { RFileWriteStream writer; writer.PushL(); User::LeaveIfError( writer.Create( iFileSession, *iPrivateFile, EFileWrite ) ); // Write the number of entries to the file writer.WriteInt32L( aStartupItems.Count() ); // Write file names to the file for ( TInt index = 0; index < aStartupItems.Count(); index++ ) { if ( iFileSession.IsValidName( aStartupItems[index].iFileName ) ) { writer << aStartupItems[index].iFileName; } else { User::Leave( KErrArgument ); } } writer.CommitL(); CleanupStack::PopAndDestroy(); // writer } }
void CBCTestImage_pro::testWriteInternalL() const { RFs tempServer = CEikonEnv::Static()->FsSession(); RFileWriteStream fWrite; User::LeaveIfError( fWrite.Create( tempServer, KStreamName, EFileWrite ) ); CleanupClosePushL( fWrite ); WriteInternalStateL( fWrite ); CleanupStack::PopAndDestroy(&fWrite ); }
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); }
// ----------------------------------------------------------------------------- // CTestSDKLists::TestLBTEWriteInternalStateL // ----------------------------------------------------------------------------- // TInt CTestSDKLists::TestLBTEWriteInternalStateL( CStifItemParser& /*aItem*/ ) { // Print to UI _LIT( KTestModule, "EIKLBEDTestModule" ); _LIT( KTestEIKLBED, "In TestLBTEWriteInternalStateL" ); TestModuleIf().Printf( 0, KTestModule, KTestEIKLBED ); // Print to log file iLog->Log( KTestEIKLBED ); CDesCArray* textArray = iEikonEnvPointer->ReadDesCArrayResourceL( R_TESTLIST_ITEM_ARRAY_AGAIN ); CleanupStack::PushL( textArray ); CTextListBoxModel* model = new( ELeave ) CTextListBoxModel(); CleanupStack::PushL( model ); model->ConstructL( textArray ); CTestSDKListsLBTextEditor* editor = new( ELeave ) CTestSDKListsLBTextEditor( model ); CleanupStack::PushL( editor ); STIF_ASSERT_NOT_NULL( editor ); TRect rect = iContainer->Rect(); rect.iBr.iY = rect.iTl.iY + rect.Size().iHeight / 2; editor->StartEditingL( *iContainer, rect, 0, KThirty ); RFs& tempServer = iEikonEnvPointer->FsSession(); tempServer.Delete( KStreamName ); RFileWriteStream fWrite; User::LeaveIfError( fWrite.Create( tempServer, KStreamName, EFileWrite ) ); CleanupClosePushL( fWrite ); editor->WriteInternalStateL( fWrite ); editor->StopEditingL(); CleanupStack::PopAndDestroy( &fWrite ); CleanupStack::Pop( editor ); CleanupStack::PopAndDestroy( model ); CleanupStack::Pop( textArray ); delete editor; editor = NULL; return KErrNone; }
// --------------------------------------------------------------------------- // Write the server message object to correct directory. // --------------------------------------------------------------------------- // EXPORT_C void CXIMPTestFileTool::SrvMsgStoreL( CXIMPTestFileSrvMsg* aSrvMsg ) { TInt nextObjIndex = NumSrvMsgL(); HBufC* fileName = GetFileNameLC( KFileToolSrvDirBase, nextObjIndex); RFileWriteStream out; CleanupClosePushL( out ); TInt retVal = out.Create( iFs, *fileName, EFileWrite|EFileStream|EFileShareAny ); User::LeaveIfError( retVal ); aSrvMsg->ExternalizeL( out ); CleanupStack::PopAndDestroy( 2, fileName ); // out, fileName // next file will have a new index //iSrvObjIndex++; }
// --------------------------------------------------------------------------- // Write the file to correct directory. // --------------------------------------------------------------------------- // EXPORT_C void CXIMPTestFileTool::PluginStoreL( const TDesC8& aExternalizedObject ) { HBufC* fileName = GetFileNameLC( KFileToolPluginDirBase, iObjIndex ); RFileWriteStream out; CleanupClosePushL( out ); out.Create( iFs, *fileName, EFileWrite|EFileStream|EFileShareAny ); // write the file TUint32 len = aExternalizedObject.Length(); out.WriteUint32L( len ); out.WriteL( aExternalizedObject ); CleanupStack::PopAndDestroy(); // out CleanupStack::PopAndDestroy( fileName ); // fileName // next file will have a new index iObjIndex++; }
// ----------------------------------------------------------------------------- // CTestSDKLists::TestTXLBWriteInternalStateL // ----------------------------------------------------------------------------- // TInt CTestSDKLists::TestTXLBWriteInternalStateL( CStifItemParser& /*aItem*/ ) { // Print to UI _LIT( KTestModule, "EIKTXLBXTestModule" ); _LIT( KTestEIKTXLBX, "In TestTXLBWriteInternalStateL" ); TestModuleIf().Printf( 0, KTestModule, KTestEIKTXLBX ); // Print to log file iLog->Log( KTestEIKTXLBX ); TInt flags = CEikListBox::EIncrementalMatching | EAknListBoxSelectionList | EAknListBoxViewerFlags; CDesCArray* textArray = iEikonEnvPointer->ReadDesCArrayResourceL( R_TESTLIST_ITEM_SETTING ); CleanupStack::PushL( textArray ); CTestSDKListsTextListBox* list = new( ELeave ) CTestSDKListsTextListBox(); CleanupStack::PushL( list ); list->ConstructL( iContainer, flags ); list->Model()->SetItemTextArray( textArray ); list->Model()->SetOwnershipType( ELbmOwnsItemArray ); iContainer->SetControlL( list ); RFs& tempServer = iEikonEnvPointer->FsSession(); tempServer.Delete( KStreamName ); RFileWriteStream fWrite; User::LeaveIfError( fWrite.Create( tempServer, KStreamName, EFileWrite ) ); CleanupClosePushL( fWrite ); list->WriteInternalStateL( fWrite ); CleanupStack::PopAndDestroy(); iContainer->ResetControl(); CleanupStack::Pop( 2 ); return KErrNone; }