/** @SYMTestCaseID SYSLIB-STORE-CT-1127 @SYMTestCaseDesc Stream encryption test. Tests the functionality of REncryptStream and RDecryptStream classes @SYMTestPriority High @SYMTestActions Tests for writing an encrypted string to a stream,reading back the data,decrypt and check with the original data. @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ LOCAL_C void testSimpleStreamEncryptionL() { test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1127 ")); CPBEncryptElement* elementKey = CPBEncryptElement::NewL(KTestPassword); CleanupStack::PushL(elementKey); TParsePtrC parse(KFileLocationSpec); RFileWriteStream writeStream; writeStream.PushL(); User::LeaveIfError(writeStream.Replace(TheFs, parse.NameAndExt(), EFileWrite)); REncryptStream encryptStream; encryptStream.OpenLC(writeStream, *elementKey); encryptStream << KTestDes; encryptStream.CommitL(); writeStream.CommitL(); CleanupStack::PopAndDestroy(2); // encryptStream, writeStream RFileReadStream readStream; readStream.PushL(); User::LeaveIfError(readStream.Open(TheFs, parse.NameAndExt(), EFileWrite)); RDecryptStream decryptStream; decryptStream.OpenLC(readStream, *elementKey); decryptStream >> TheBuf; test(KTestDes == TheBuf); CleanupStack::PopAndDestroy(3, elementKey); // decryptStream, readStream }
/** exports all contacts items in db to vcard file, if aDelete, cleans database afterwards */ void CPerformanceFunctionalityBase::ExportVcardL(const TBool aDelete, const TDesC &aVCard) { iIterate->Reset(); CContactIdArray *ids = CContactIdArray::NewLC(); TInt i = 0; for(; i < iContacts; ++i) { ids->AddL( iIterate->NextL() ); } RFileWriteStream rfws; CleanupClosePushL(rfws); User::LeaveIfError( rfws.Replace( iParent->Fs(),aVCard , EFileWrite | EFileShareAny ) ); iContactsDatabase->ExportSelectedContactsL( TUid::Uid(KUidVCardConvDefaultImpl), *ids, rfws, CContactDatabase::EIncludeX | CContactDatabase::ETTFormat ); CleanupStack::PopAndDestroy(&rfws); if( aDelete ) { CLEAR( iContactsDatabase ); iContactsDatabase = CContactDatabase::ReplaceL(); } CleanupStack::PopAndDestroy(ids); }
void CApaAppListServer::ExternalizeNonNativeApplicationTypeArrayL(TInt aIndexToIgnore/*=-1*/) const { RFs& fs=const_cast<RFs&>(iFs); fs.MkDirAll(iNonNativeApplicationTypeRegistry); // ignore any error RFile file; CleanupClosePushL(file); User::LeaveIfError(file.Replace(fs, iNonNativeApplicationTypeRegistry, EFileShareExclusive|EFileStream|EFileWrite)); RFileWriteStream targetStream; targetStream.Attach(file); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns) CleanupClosePushL(targetStream); const TInt arrayCount(iNonNativeApplicationTypeArray.Count()); TInt arrayCountToExternalize=arrayCount; if (aIndexToIgnore>=0) { --arrayCountToExternalize; } TCardinality(arrayCountToExternalize).ExternalizeL(targetStream); for (TInt i=0; i<arrayCount; ++i) { if (i!=aIndexToIgnore) { const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i]; targetStream.WriteUint32L(nonNativeApplicationType.iTypeUid.iUid); targetStream << *nonNativeApplicationType.iNativeExecutable; } } targetStream.CommitL(); CleanupStack::PopAndDestroy(2, &file); }
// ----------------------------------------------------------------------------- // 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 CCmdCustomCommand::WriteHandleToFileL(TInt aHandle) { const TChar sysDrive = RFs::GetSystemDriveChar(); RBuf filename; filename.CreateL(KNeverUnloadLibHandleFile().Length() + 1); filename.Append(sysDrive); filename.Append(KNeverUnloadLibHandleFile()); filename.CleanupClosePushL(); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); fs.MkDirAll(filename); // ignore any error RFile file; CleanupClosePushL(file); TInt err=KErrNone; TInt pos = 0; if(KErrNotFound == (err = file.Open(fs, filename, EFileShareExclusive|EFileStream|EFileWrite))) { User::LeaveIfError(file.Replace(fs, filename, EFileShareExclusive|EFileStream|EFileWrite)); } else { User::LeaveIfError(err); file.Seek(ESeekEnd, pos); } RFileWriteStream targetStream; targetStream.Attach(file, pos); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns) CleanupClosePushL(targetStream); targetStream.WriteInt32L(aHandle); targetStream.CommitL(); CleanupStack::PopAndDestroy(4); }
/** @SYMTestCaseID SYSLIB-SQL-CT-1635 @SYMTestCaseDesc RSqlSecurityPolicy test. Tests RSqlSecurityPolicy API. @SYMTestPriority High @SYMTestActions RSqlSecurityPolicy test. @SYMTestExpectedResults Test must not fail @SYMREQ REQ5792 REQ5793 */ void SqlSecurityPolicyTest() { RSqlSecurityPolicy securityPolicy; TInt err = securityPolicy.Create(KDefaultPolicy); TEST2(err, KErrNone); //Empty RSqlSecurityPolicy object tests //Database policies TSecurityPolicy policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy); TEST(policy == KDefaultPolicy); policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EReadPolicy); TEST(policy == KDefaultPolicy); policy = securityPolicy.DbPolicy(RSqlSecurityPolicy::EWritePolicy); TEST(policy == KDefaultPolicy); //Table policies policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("A-Tbl"), RSqlSecurityPolicy::EReadPolicy); TEST(policy == KDefaultPolicy); policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("B-Tbl"), RSqlSecurityPolicy::EWritePolicy); TEST(policy == KDefaultPolicy); // securityPolicy.Close(); //Tests with initialized RSqlSecurityPolicy object CreateTestSecurityPolicy(securityPolicy); //Check the created and initialized object CheckTestSecurityPolicy(securityPolicy); //Externalize, then internalize and check the security policy object RFileWriteStream out; err = out.Replace(TheFs, KTestFile, EFileRead | EFileWrite); TEST2(err, KErrNone); TRAP(err, securityPolicy.ExternalizeL(out)); TEST2(err, KErrNone); TRAP(err, out.CommitL()); out.Close(); TEST2(err, KErrNone); securityPolicy.Close(); err = securityPolicy.Create(KDefaultPolicy); TEST2(err, KErrNone); RFileReadStream in; err = in.Open(TheFs, KTestFile, EFileRead); TEST2(err, KErrNone); TRAP(err, securityPolicy.InternalizeL(in)); in.Close(); TEST2(err, KErrNone); CheckTestSecurityPolicy(securityPolicy); //Change some security policies and check that the RqlSecurityPolicy content was properly updated err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EReadPolicy, KPolicy3); TEST2(err, KErrNone); policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName1, RSqlSecurityPolicy::EReadPolicy); TEST(policy == KPolicy3); policy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, KTableName11, RSqlSecurityPolicy::EWritePolicy); TEST(policy == KPolicy2); // securityPolicy.Close(); }
/** ssmtestapprvafterretry.exe is eventually invoked successfully. SsmStartSafe is configured to make 1 + retries attempts to start the recalcitrant app. The app is configured to start after retries attempts */ void CSsTestStepAppStart::DoTestAppStartWithRetriesL() { INFO_PRINTF1( _L("\nStart recalcitrant app with retries") ); // // Write the retry number to a file to be read, updated // and eventually deleted by the test-app. RFs fs; CleanupClosePushL( fs ); RFileWriteStream writeStream; CleanupClosePushL( writeStream ); if( KErrNone != fs.Connect() || KErrNone != writeStream.Replace(fs, KDontRvCountFile, EFileWrite) ) { User::Leave( KErrCouldNotConnect ); } const TInt KSsTestDontRvCount = 4; writeStream.WriteInt8L( KSsTestDontRvCount ); writeStream.CommitL(); CleanupStack::PopAndDestroy( 2, &fs ); // const TInt KRetries = KSsTestDontRvCount + 1; CSsmStartupProperties* startupProperties_0 = CSsmStartupProperties::NewL(); CleanupStack::PushL( startupProperties_0 ); startupProperties_0->SetFileParamsL( KTestAppRvAfterRetry, KNullDesC ); startupProperties_0->SetCommandTypeL( ESsmCmdStartApp ); startupProperties_0->SetExecutionBehaviour( ESsmWaitForSignal ); startupProperties_0->SetRetries( KRetries ); // For each retry KTestAppRvAfterRetry takes 2secs startupProperties_0->SetTimeout( KSsTestAppStartTimeout*1.5 ); RProcess process; TInt id_0 = 0; CStartAcknowledge* ack_0 = new(ELeave) CStartAcknowledge( this ); CleanupStack::PushL( ack_0 ); CSsmStartSafe* ss = CSsmStartSafe::NewLC(); ss->Start(*startupProperties_0, process, ack_0->iStatus, id_0); CAsPauseStopper* pauseStopper = new(ELeave) CAsPauseStopper( KSsAsStopperNominalTimeout * 10 ); CleanupStack::PushL( pauseStopper ); CActiveScheduler::Start(); process.Close(); TEST( ack_0->iStatus == KErrNone ); CleanupStack::PopAndDestroy( 4, startupProperties_0 ); TEST( 1 == FindAndKill(KTestAppRvAfterRetry) ); }
TInt CSenBaseIdentityManager::WriteConfigurationToL( const TDesC& aFile ) { // First, collect everything into MEMORY CBufFlat *pBuf = CBufFlat::NewL(KFLATBUF_SIZE); CleanupStack::PushL(pBuf); RBufWriteStream bufWs(*pBuf); CleanupClosePushL(bufWs); bufWs.WriteL(KUsersStart); if(iIdentity) { iIdentity->WriteAsXMLToL(bufWs); } bufWs.WriteL(KUsersEnd); TPtrC8 p8 = pBuf->Ptr(0); CleanupStack::PopAndDestroy(1); // bufWs // Everything in MEMORY ok, prepare to write into file RFs fss; User::LeaveIfError(fss.Connect()); CleanupClosePushL(fss); RFileWriteStream fileOutStream; CleanupClosePushL(fileOutStream); if(!SysUtil::FFSSpaceBelowCriticalLevelL(&fss, p8.Length()) ) { // note, this will zero-length the file(!) // it is better to require that 2xfilesize is available and not to // dangerously zero the old file and find out // that there is no space left.. //Data caging 2 implementation #if defined( EKA2 ) || defined( RD_SECURE_PRIV_DATA ) TBuf<KMaxPath> file; fss.CreatePrivatePath(EDriveC); fss.PrivatePath(file); file.Append(aFile); fileOutStream.Replace(fss, file, EFileWrite); #else fileOutStream.Replace(fss, aFile, EFileWrite); #endif // finally write the UTF-8 into the file. fileOutStream.WriteL(p8); } CleanupStack::PopAndDestroy(3); // fileOutStream, fss, pBuf return KErrNone; }
void CAccessCountTests::ExportVcardL(const CContactIdArray &aConids) { RFileWriteStream rfws; CleanupClosePushL(rfws); User::LeaveIfError( rfws.Replace( iParent->Fs(), KVcardFile, EFileWrite | EFileShareAny ) ); iContactsDatabase->ExportSelectedContactsL( TUid::Uid(KUidVCardConvDefaultImpl), aConids, rfws, CContactDatabase::EIncludeX | CContactDatabase::ETTFormat ); CleanupStack::PopAndDestroy(&rfws); }
void CRequestManager::SaveConfigInfoL() { FLOG(_L("[IMAGEPRINTUI]<<< CEventManager;SaveConfigInfoL ")); RFileWriteStream stream; CleanupClosePushL(stream); if((stream.Replace(CCoeEnv::Static()->FsSession(),iCongFileName->Des() ,EFileWrite)) == KErrNone) { ExternalizeL(stream); } CleanupStack::PopAndDestroy(&stream); }
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 ); }
// ----------------------------------------------------------------------------- // CDRMHelperServer::StoreL(). // This function store internal list into data file // ----------------------------------------------------------------------------- // void CDRMHelperServer::StoreL() { #ifdef _DRM_TESTING WriteL(_L8("StoreL")); #endif RFileWriteStream file; User::LeaveIfError(file.Replace( iFs , DataFileL(iFs).FullName() , EFileWrite )); file.PushL(); ExternalizeL(file); file.CommitL(); CleanupStack::PopAndDestroy(&file);//file }
// ---------------------------------------------------------------------------- // CAudioStreamEngine::SaveAudioFileL() // // saves the audio data in the buffer into a file // ---------------------------------------------------------------------------- void CAudioStreamEngine::SaveAudioFileL() { if (!iBufferOK) { // In case the encoding was changed between recording and trying to save the file ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Recorded buffer does not match current encoding."), ETrue); ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Please re-record and try again."), EFalse); return; } RFileWriteStream audiofile; // Check for free space for saving the sample TVolumeInfo volinfo; TInt err=iFs.Volume(volinfo,EDriveC); if ( volinfo.iFree<(iFrameCount*iFrameSize)) { // Not enough free space on drive for saving, report and exit ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Cannot save file:\nnot enough space!"), ETrue); return; } TFileName fileName; fileName.Copy(iAudioFilePath); fileName.Append(iAudioFile); err = audiofile.Replace(iFs, fileName, EFileWrite|EFileStream); if (err==KErrNone) { if (iUseAMR) { // Write the six-byte AMR header, so that the file can be used by other // applications as well. for (int i = 0; i < KAMRHeaderLength; i++) audiofile.WriteUint8L(KAMRNBHeader[i]); } // File opened ok, proceed writing. // Write audio data directly from iStreamBuffer for (TUint idx=iStreamStart; idx<=iStreamEnd; idx++)//iFrameCount; idx++) { audiofile.WriteL(GetFrame(idx)); } ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Saving complete!"), ETrue); } else { // failed to open file ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Error saving audio sample!"), ETrue); } audiofile.Close(); }
void Cdmatest::SaveMappingsL() { TInt c( iMappingTable.Count() ); if ( c > 0 ) { RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL( fs ); RFileWriteStream buf; User::LeaveIfError( buf.Replace( fs, KMappingTableFile, EFileWrite ) ); CleanupClosePushL( buf ); TInt i( 0 ) ; do { buf.WriteUint32L( iMappingTable[i].iURI.Length() ); buf.WriteL( iMappingTable[i].iURI ); buf.WriteUint32L( iMappingTable[i].iLuid.Length() ); buf.WriteL( iMappingTable[i].iLuid ); } while ( ++i < c ) ; buf.CommitL(); buf.Close(); CleanupStack::PopAndDestroy(); // buf CleanupStack::PopAndDestroy(); // fs } }
void ExportEntriesL(RPointerArray<CCalEntry>& aCalEntries, const TDesC& aFileName) { TEntry dirEntry; // Create a directory if not present if (calTestLibrary->FileSession().Entry(KWriteDataDir(), dirEntry) != KErrNone) { calTestLibrary->FileSession().MkDir(KWriteDataDir()); } RFileWriteStream fileWriteStream; CleanupClosePushL(fileWriteStream); User::LeaveIfError(fileWriteStream.Replace(calTestLibrary->FileSession(), aFileName, EFileWrite)); calTestLibrary->DataExchangeL().ExportL(KUidVCalendar, fileWriteStream, aCalEntries); CleanupStack::PopAndDestroy(&fileWriteStream); }
/** Overload of the CCoeAppUi virtual method. The method in the base class merely returns ETrue. Overloads would normally just return EFalse. In this case however, we do some jiggery-pokery in order to invoke the StartSafe retry mechanism. ie we return EFalse on each of several invocations but don't do the Rendezvous, then eventually ETrue, so the Framework Rendezvous for us. our final invocation therefore being successful. The count file is written from the test-step, and if successful, deleted here. The code is nearly all parenthesised within a TRAP harness in order to preserve the integrity of this function, which is called by the framework. */ TBool CTestAppUi::FrameworkCallsRendezvous() const { TBool frameworkRendezvous = EFalse; TRAPD( err, { RFs fs; RFileReadStream readStream; RFileWriteStream writeStream; CleanupClosePushL( fs ); CleanupClosePushL( readStream ); CleanupClosePushL( writeStream ); if( KErrNone != fs.Connect() || KErrNone != readStream.Open(fs, KDontRvCountFile, EFileRead) ) { User::Leave( KErrCouldNotConnect ); } TInt failCount = readStream.ReadInt8L(); readStream.Close(); if( 0 == failCount ) { fs.Delete( KDontRvCountFile ); // We've decided to be good this time. Let the framework do it for us. frameworkRendezvous = ETrue; } else { // StartSafe will timeout while waiting for a Rendezvous() User::LeaveIfError( writeStream.Open(fs, KDontRvCountFile, EFileWrite) ); writeStream.WriteInt8L( --failCount ); writeStream.CommitL(); writeStream.Close(); } CleanupStack::PopAndDestroy( 3, &fs ); } );
// ----------------------------------------------------------------------------- // 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; }
void VersitExportContactL(const TDesC& aExportFileName) { RFileWriteStream writeStream; User::LeaveIfError(writeStream.Replace(fsSession, aExportFileName, EFileWrite)); CleanupClosePushL(writeStream); CContactIdArray* idArray = CContactIdArray::NewLC(); TInt count = CntTest->Db()->CountL(); test(count == 1); TContactItemId contactId = CntTest->Db()->GetCurrentItem(); idArray->InsertL(0, contactId); CntTest->Db()->ExportSelectedContactsL(TUid::Uid(KUidVCardConvDefaultImpl), *idArray, writeStream,0); writeStream.Close(); CleanupStack::PopAndDestroy(2); //idArray, writeStream }
// --------------------------------------------------------------------------- // 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++; }
void TTcSettings::Store() { // Connect to file server RFs fs; if( fs.Connect() ) { return; } // Open the settings file for writing, replace any existing data RFileWriteStream out; if( !out.Replace( fs, KTcSettingsFile, EFileWrite ) ) { // Write actual data, ignore errors TRAP_IGNORE( doStoreL( out ) ) } out.Close(); fs.Close(); }
/** Write the results to the result file, to be later extracted by testexecute test case. These contain the results of the individual tests. The order in which these results are written in MUST match the order in which they are read and tested in CSysStartApparcTestStep::GetApparcResultsL() and the expected result tested in CSysStartApparcTestStep::Testxxx must match that in the test specification\n The format is: StartApp1LRes1 count=value1 StartApp1LRes2 count=value2 '=' is used as the deliminator. */ void CSysStartApparcTestCase::WriteResultFileL() { RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); RFileWriteStream writer; User::LeaveIfError(writer.Replace(fs, KSsaacResultFile, EFileWrite)); CleanupClosePushL(writer); // write data to file writer << _L("StartApp1LRes1 count="); writer.WriteInt16L(iStartApp1LRes1); writer << _L("\n"); writer << _L("StartApp1LRes2 count="); writer.WriteInt16L(iStartApp1LRes2); writer << _L("\n"); writer.CommitL(); CleanupStack::PopAndDestroy(2, &fs); }
////////////////////////////////////////////////////////////////////////////////// // Test fix for INC023303: CX509Certificate externalize - internalize don't work ////////////////////////////////////////////////////////////////////////////////// void CSyntaxTest::TestInternalizeExternalizeL(CX509Certificate* aCert) { RFileWriteStream newwriter; newwriter.PushL(); User::LeaveIfError(newwriter.Replace(iFs,_L("x509stream"),EFileStream)); aCert->ExternalizeL(newwriter); newwriter.CommitL(); CleanupStack::PopAndDestroy(1);//newwriter RFileReadStream newreader; newreader.PushL(); newreader.Open(iFs,_L("x509stream"),EFileStream); CX509Certificate* readCert=CX509Certificate::NewLC(newreader); //Use the stream to create new cert if (!readCert->IsEqualL(*aCert)) User::Leave(KErrGeneral); // iFs.Delete(_L("x509stream")); CleanupStack::PopAndDestroy(2); // readCert, newreader }
// --------------------------------------------------------------------------- // 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++; }
//存档 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(); }
/** @SYMTestCaseID PDS-STORE-CT-4042 @SYMTestCaseDesc Tests for attaching write stream and read stream to an encrypted stream. @SYMTestPriority High @SYMTestActions Encrypt data and write to a store.Read the encrypted data for decrypting and compare the result. @SYMTestExpectedResults Test must not fail @SYMDEF DEF135804 */ LOCAL_C void testEncryptionDataAttachL() { test.Next(_L(" @SYMTestCaseID:PDS-STORE-CT-4042 ")); CPBEncryptElement* elementKey = CPBEncryptElement::NewLC(KTestPassword); TParsePtrC parse(KFileLocationSpec); RFileWriteStream writeStream; writeStream.PushL(); User::LeaveIfError(writeStream.Replace(TheFs, parse.NameAndExt(), EFileWrite)); REncryptStream encryptStream; TRAPD(ret, encryptStream.AttachL(writeStream, *elementKey)); test(ret == KErrNone); encryptStream.PushL(); encryptStream << KTestDes; encryptStream.CommitL(); writeStream.CommitL(); CleanupStack::PopAndDestroy(2); // encryptStream, writeStream const CPBEncryptionData& encryptData = elementKey->EncryptionData(); CPBEncryptElement* newElementKey = CPBEncryptElement::NewLC(encryptData, KTestPassword); RFileReadStream readStream; readStream.PushL(); User::LeaveIfError(readStream.Open(TheFs, parse.NameAndExt(), EFileWrite)); RDecryptStream decryptStream; decryptStream.AttachL(readStream, *newElementKey); decryptStream.PushL(); decryptStream >> TheBuf; test(KTestDes == TheBuf); CleanupStack::PopAndDestroy(4, elementKey); }
/** @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); }
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); }
// --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // void CPolicyClientRequestHandler::DumpClientsL(RFileWriteStream& aFile) { // Lint seems to have some trouble identifying the TThreadId class. // Due to this, Lint will report several errors here that are incorrect. // These errors are disabled. /*lint -e10 -e1013 -e1055 -e746 -e747 */ for(TInt i = iControlPolicyClients.Count() - 1; i >= 0; i--) { TPckgC<TThreadId> clientid(iControlPolicyClients[i]->iClientId.Id()); aFile.WriteL(clientid); } /*lint +e10 +e1013 +e1055 +e746 +e747 */ }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CNcdProviderUtils::WriteDatabaseVersionsL( const TDesC& aRootPath, TUint32 aGeneralVersion, TUint32 aPurchaseHistoryVersion ) { DLTRACEIN(("Writing versions, general: %d, purchase history: %d", aGeneralVersion, aPurchaseHistoryVersion )); RBuf path; AppendPathsLC( path, aRootPath, NcdProviderDefines::KNcdDatabaseVersionFile ); RFileWriteStream stream; CleanupClosePushL( stream ); User::LeaveIfError( stream.Replace( FileSession(), path, EFileWrite ) ); stream.WriteUint32L( aGeneralVersion ); stream.WriteUint32L( aPurchaseHistoryVersion ); CleanupStack::PopAndDestroy( 2, &path ); DLTRACEOUT(("Versions successfully written")); }
// ----------------------------------------------------------------------------- // 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; }