本文整理汇总了C++中CFileStore::CommitL方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileStore::CommitL方法的具体用法?C++ CFileStore::CommitL怎么用?C++ CFileStore::CommitL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileStore
的用法示例。
在下文中一共展示了CFileStore::CommitL方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterScriptL
void CSecMgrStore::RegisterScriptL(TExecutableID aExecID, const CScript& aScript)
{
HBufC *scriptFile = HBufC::NewLC(KMaxName);
TPtr ptr(scriptFile->Des());
User::LeaveIfError(GetScriptFile(ptr,aExecID));
CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr,
EFileWrite);
// Must say what kind of file store.
store->SetTypeL (KPermanentFileStoreLayoutUid);
// Construct the output stream.
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC (*store);
aScript.ExternalizeL (outstream);
// Commit changes to the stream
outstream.CommitL ();
// Cleanup the stream object
CleanupStack::PopAndDestroy (&outstream);
// Set this stream id as the root
store->SetRootL (id);
// Commit changes to the store
store->CommitL ();
CleanupStack::PopAndDestroy (store);
CleanupStack::PopAndDestroy (scriptFile);
}
示例2: CreateL
//SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
EXPORT_C void CDbFileStoreDatabase::CreateL(const TDesC& aName, TDbFormat::TCreate aMode,
const TUidType& aType)
{
__ASSERT(!iName); // check construction phase
//
iName=aName.AllocL();
CFileStore* store;
switch (aMode)
{
default:
__LEAVE(KErrNotSupported);
case TDbFormat::ECreate:
store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite);
break;
case TDbFormat::EReplace:
store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite);
break;
};
iStore=store;
iDelete=ETrue; // cleanup fully in case of failure
store->SetTypeL(aType);
store->SetRootL(CreateRootL(CDbStoreDatabase::ConstructL()));
store->CommitL();
iDelete=EFalse; // file is now good
}
示例3: StorePolicyL
void CSecMgrStore::StorePolicyL(const CPolicy& aPolicy)
{
__UHEAP_MARK;
HBufC *policyFile = HBufC::NewLC(KMaxName);
TPtr ptr(policyFile->Des());
GetPolicyFile (ptr, aPolicy.PolicyID ());
CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr,
EFileWrite);
store->SetTypeL (KPermanentFileStoreLayoutUid);
// Construct the output stream.
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC (*store);
//Write version of the policy
outstream.WriteReal32L (TReal(DEFAULT_VERSION));
TInt aliasCnt(aPolicy.AliasGroup().Count());
outstream.WriteInt32L (aliasCnt);
RAliasGroup aliasGroups = aPolicy.AliasGroup();
for (TInt i(0); i!=aliasCnt;++i)
{
CPermission* alias = aliasGroups[i];
alias->ExternalizeL (outstream);
}
TInt domainCnt(aPolicy.ProtectionDomain().Count ());
outstream.WriteInt32L (domainCnt);
RProtectionDomains domains = aPolicy.ProtectionDomain ();
for (TInt i(0); i!=domainCnt;++i)
{
CProtectionDomain* domain = domains[i];
domain->ExternalizeL (outstream);
}
// Commit changes to the stream
outstream.CommitL ();
CleanupStack::PopAndDestroy (&outstream);
// Set this stream id as the root
store->SetRootL (id);
// Commit changes to the store
store->CommitL ();
CleanupStack::PopAndDestroy (store);
CleanupStack::PopAndDestroy (policyFile);
__UHEAP_MARKEND;
}
示例4: doMakeAndExternalizeL
LOCAL_C void doMakeAndExternalizeL(const TDesC& aName)
{
TParse filestorename;
fsSession.Parse(aName,filestorename);
// construct file store object - the file to contain the
// the store replaces any existing file of the same name.
CFileStore* store = CPermanentFileStore::ReplaceLC(fsSession,filestorename.FullName(),EFileWrite);
// Must say what kind of file store
store->SetTypeL(KPermanentFileStoreLayoutUid);
// Construct an object of type CCompound ...
CCompound* thecompound = CCompound::NewLC(*store);
// ... and put some data into it.
// Note that "iA->" achieves the same
// as "iA->AsPtr()->"
_LIT(KTxtClassAText,"CClassA text");
_LIT(KTxtClassBText,"CClassB text");
thecompound->iA.AsPtr()->iBufferA = KTxtClassAText;
thecompound->iA.AsPtr()->iXA = -1;
thecompound->iA->iYA = 2; // see note above
thecompound->iB.AsPtr()->iBufferB = KTxtClassBText;
thecompound->iC.AsPtr()->iZC = 3.456;
// Show contents of the CCompound object (and its
// components).
_LIT(KTxtInitialContent,"... Initial content of CCompound");
doShowAll(KTxtInitialContent,*thecompound);
// stores all components as separate streams and
// then streams the store map
TStreamId id = thecompound->StoreL();
// Set the stream id as the root
store->SetRootL(id);
// Commit changes to the store
store->CommitL();
// Destroy:
// 1. the CCompound object
// 2. the store object (this also closes
// the file containing the store)
// Remove both from the cleanup stack
CleanupStack::PopAndDestroy(2);
}
示例5: doMakeAndExternalizeL
LOCAL_C void doMakeAndExternalizeL(const TDesC& aName)
{
TParse filestorename;
fsSession.Parse(aName,filestorename);
// construct file store object - the file to contain the
// the store replaces any existing file of the same name.
CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,filestorename.FullName(),EFileWrite);
// Must say what kind of file store
store->SetTypeL(KDirectFileStoreLayoutUid);
// Construct an object of type CCompound
// and put some data into it.
CCompound* thecompound = CCompound::NewLC();
_LIT(KTxtClassAText,"CClassA text");
_LIT(KTxtClassBText,"CClassB text");
thecompound->iCa->iBufferA = KTxtClassAText;
thecompound->iCa->iXA = -1;
thecompound->iCa->iYA = 2;
thecompound->iCb->iBufferB = KTxtClassBText;
thecompound->iTc.iZC = 3.456;
// Show contents of the CCompound object (and its
// components)
_LIT(KTxtInitialContent,"... Initial content of CCompound");
doShow(KTxtInitialContent,*thecompound);
// Store the compound object to a single stream
// and save the stream id as the root id.
TStreamId id = thecompound->StoreL(*store);
// Set the stream id as the root
store->SetRootL(id);
// Commit changes to the store
store->CommitL();
// Destroy:
// 1. the CCompound object
// 2. the store object (this also closes
// the file containing the store)
// Remove both from the cleanup stack
CleanupStack::PopAndDestroy(2);
}
示例6: StreamLC
void CVersitTest::StreamLC(RReadStream& aStream)
{
GetSampleVersitL();
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersitIn"),EFileWrite);
store->SetTypeL(KDirectFileStoreLayoutUid);
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
TInt length=iVersit.Length();
for (TInt ii=0; ii<length; ii++)
outstream.WriteInt8L(iVersit[ii]);
outstream.CommitL();
CleanupStack::PopAndDestroy();
store->SetRootL(id);
store->CommitL();
CleanupStack::PopAndDestroy(); // store
store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersitIn"),EFileRead); //retrieve stream
RStoreReadStream instream;
instream.OpenLC(*store,store->Root());
CleanupStack::Pop(); // instream
aStream=RReadStream(instream);
}
示例7: CreateServerMtmRegL
EXPORT_C void CMsvTestUtils::CreateServerMtmRegL(const TUid aMsgType, const TDesC& aHumanReadableName, const TMsvTestDllInfo& aServerMtm, const TMsvTestDllInfo& aClientMtm, const TMsvTestDllInfo& aUiMtm, const TMsvTestDllInfo& aUiDataMtm, const TUid aGroup, const TDesC& aDatFile)
{
CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray();
CleanupStack::PushL(mtmdllinfoarray);
CMtmDllInfo* mtmdllinfo1=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmServerComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aServerMtm.iFileName,aServerMtm.iOrdinal,aServerMtm.iVersion);
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo1);
CMtmDllInfo* mtmdllinfo2=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmClientComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aClientMtm.iFileName,aClientMtm.iOrdinal,aClientMtm.iVersion);
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo2);
CMtmDllInfo* mtmdllinfo3=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiMtm.iFileName,aUiMtm.iOrdinal,aUiMtm.iVersion);
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo3);
CMtmDllInfo* mtmdllinfo4=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiDataComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiDataMtm.iFileName,aUiDataMtm.iOrdinal,aUiDataMtm.iVersion);
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo4);
// Create an empty capability set for creating a new group data object
TCapabilitySet capSet;
capSet.SetEmpty();
CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership
CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(aMsgType, aGroup, mtmdllinfoarray, capSet);
CleanupStack::PushL(mtmgroupdata);
CFileStore* filestore = CPermanentFileStore::ReplaceLC(FileSession(), aDatFile, EFileShareExclusive|EFileStream|EFileWrite);
TUidType uidtype(KPermanentFileStoreLayoutUid, KUidMsvDataComponent, aMsgType);
filestore->SetTypeL(uidtype);
RStoreWriteStream out;
TStreamId streamid=out.CreateLC(*filestore); // Push to stack
mtmgroupdata->ExternalizeL(out);
out.CommitL();
CleanupStack::PopAndDestroy(); // out
filestore->SetRootL(streamid);
filestore->CommitL();
CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata
}
示例8: WriteCounter
TInt CSecMgrStore::WriteCounter(TExecutableID aExecID)
{
HBufC *configFile = HBufC::NewLC(KMaxName);
TPtr ptr(configFile->Des());
TInt ret(GetConfigFile (ptr));
if ( KErrNone==ret)
{
CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession,
*configFile, EFileWrite);
// Must say what kind of file store.
store->SetTypeL (KPermanentFileStoreLayoutUid);
// Construct the output stream.
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC (*store);
outstream.WriteInt32L (aExecID);
// Commit changes to the stream
outstream.CommitL ();
// Cleanup the stream object
CleanupStack::PopAndDestroy (&outstream);
// Set this stream id as the root
store->SetRootL (id);
// Commit changes to the store
store->CommitL ();
CleanupStack::PopAndDestroy (store);
}
CleanupStack::PopAndDestroy (configFile);
return ret;
}
示例9: StreamInL
void CVersitTest::StreamInL()
//Convert the iVersit into stream format, save it as "TTVersitIn"
//and internalize it as a CVersitParser
{
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersit2"),EFileWrite);
store->SetTypeL(KDirectFileStoreLayoutUid);
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
TInt length=iVersit.Length();
for (TInt ii=0; ii<length; ii++)
outstream.WriteInt8L(iVersit[ii]);
outstream.CommitL();
CleanupStack::PopAndDestroy();
store->SetRootL(id);
store->CommitL();
CleanupStack::PopAndDestroy();
store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersit2"),EFileRead); //retrieve stream
RStoreReadStream instream;
instream.OpenLC(*store,store->Root());
iParser->InternalizeL(instream);
CleanupStack::PopAndDestroy(2); //store + stream
}
示例10: DoTestsL
LOCAL_C void DoTestsL()
{
// create test database
test.Start(_L("@SYMTESTCaseID:PIM-T-TTVERS-0001 Preparing tests"));
User::LeaveIfError(TheFs.Connect());
CleanupClosePushL(TheFs);
CTestRegister * TempFiles = CTestRegister::NewLC();
TempFiles->RegisterL(KDatabaseFileName, EFileTypeCnt);
TempFiles->RegisterL(_L("C:\\ttversitin"));
TempFiles->RegisterL(_L("C:\\ttversitin2"));
TempFiles->RegisterL(_L("C:\\ttversitin3"));
TempFiles->RegisterL(_L("C:\\ttversitout"));
TempFiles->RegisterL(_L("C:\\ttversitout.vcf"));
TempFiles->RegisterL(_L("C:\\ttversitoutb.vcf"));
TheIds=CContactIdArray::NewLC();
TRAPD(err, CContactDatabase::DeleteDatabaseL(KDatabaseFileName));
if ((err != KErrNone) && (err != KErrNotFound))
{
User::Leave(err);
}
CVersitTest* vtest=NULL;
if (vtest)
CleanupStack::PopAndDestroy(); //vtest;
vtest=new(ELeave)CVCardTest;
CleanupStack::PushL(vtest);
CVersitTest* vtest2=NULL;
vtest2=new(ELeave)CVCardTest;
CleanupStack::PushL(vtest2);
CVersitTest* vtest3=NULL;
vtest3=new(ELeave)CVCardTest;
CleanupStack::PushL(vtest3);
//Import
test.Next(_L("Importing vcard"));
CContactDatabase* db=CntTest->CreateDatabaseL();
CntTest->Db()->OverrideMachineUniqueId(0); //testcode assumes machineUID is 0
TBool success;
TUid vcardmode;
vcardmode.iUid=KUidVCardConvDefaultImpl;
RReadStream stream;
vtest->StreamLC(stream);
stream.PushL();
TheItems=db->ImportContactsL(vcardmode,stream,success,CContactDatabase::EIncludeX);
test(success);
CleanupStack::PopAndDestroy(2); // stream,store
test(db->CountL()==1);
test(TheItems->Count()==1);
test((*TheItems)[0]->UidStringL(0x0)==_L("AAA"));
//Export
test.Next(_L("Exporting vcard"));
CFileStore* store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileWrite);
store->SetTypeL(KDirectFileStoreLayoutUid);
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
TUid uid;
uid.iUid=KUidVCardConvDefaultImpl;
TInt itemCount=TheItems->Count();
for (TInt ii=0;ii<itemCount;ii++)
TheIds->AddL((*TheItems)[ii]->Id());
db->ExportSelectedContactsL(uid,*TheIds,outstream,CContactDatabase::ETTFormat);
outstream.CommitL();
store->SetRootL(id);
store->CommitL();
CleanupStack::PopAndDestroy(2); // store+ oustream
// check there are no X-EPOC
CFileStore* store2 = CDirectFileStore::OpenLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileRead); //retrieve stream
RStoreReadStream tinstream;
tinstream.OpenLC(*store2,id);
RReadStream xstream=RReadStream(tinstream);
HBufC* xdes=HBufC::NewLC(99);
TPtr ptr(xdes->Des());
xstream.ReadL(ptr);
test(xdes->Des().Match(_L("*X-*"))==KErrNotFound);
CleanupStack::PopAndDestroy(3); // store2+ instream
//DisplayDatabase(db);
test.Next(_L("Updating vcard 2"));
RReadStream stream2;
vtest2->Stream2LC(stream2);
stream2.PushL();
TheItems2=db->ImportContactsL(vcardmode,stream2,success,CContactDatabase::ETTFormat);
test(success);
CleanupStack::PopAndDestroy(2); // stream,store
test(db->CountL()==1);
//Export again
//DisplayDatabase(db);
test.Next(_L("Exporting vcard"));
TheIds->Reset();
TheIds->AddL(1);
store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitoutb.vcf"),EFileWrite);
store->SetTypeL(KDirectFileStoreLayoutUid);
id = outstream.CreateLC(*store);
uid.iUid=KUidVCardConvDefaultImpl;
itemCount=TheItems->Count();
//.........这里部分代码省略.........
示例11: testDummyL
LOCAL_C void testDummyL(CFileStore& aStore)
{
aStore.SetTypeL(aStore.Layout());
aStore.CommitL();
}
示例12: TestUiMtmLoadPanicL
LOCAL_C void TestUiMtmLoadPanicL()
{
// Make sure the server is closed
CMsgsTestUtils::WaitForServerClose();
User::After(500000);
TChar driveChar= theUtils->FileSession().GetSystemDriveChar();
TBuf<2> systemDrive;
systemDrive.Append(driveChar);
systemDrive.Append(KDriveDelimiter);
TPath pathName(systemDrive);
pathName.Append(KDefaultRegistryFileStoreName);
theUtils->FileSession().Delete(pathName);
CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray();
CleanupStack::PushL(mtmdllinfoarray);
// Create library info with silly imports
CMtmDllInfo* mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmServerComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0));
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);
mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmClientComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0));
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);
mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,345,TVersion(2,0,0));
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);
mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiDataComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,456,TVersion(2,0,0));
mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);
TCapabilitySet capSet;
capSet.SetEmpty();
CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership
CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidTestMtm, KUidTestMtm, mtmdllinfoarray, capSet);
CleanupStack::PushL(mtmgroupdata);
CFileStore* filestore = CPermanentFileStore::ReplaceLC(theUtils->FileSession(), KMtmDataFile, EFileShareExclusive|EFileStream|EFileWrite);
TUidType uidtype(KPermanentFileStoreLayoutUid,KUidMsvDataComponent, KUidTestMtm);
filestore->SetTypeL(uidtype);
RStoreWriteStream out;
TStreamId streamid=out.CreateLC(*filestore); // Push to stack
mtmgroupdata->ExternalizeL(out);
out.CommitL();
CleanupStack::PopAndDestroy(); // out
filestore->SetRootL(streamid);
filestore->CommitL();
CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata
CDummyObserver* ob = new(ELeave)CDummyObserver;
CleanupStack::PushL(ob);
CMsvSession* session = CMsvSession::OpenSyncL(*ob);
CleanupStack::PushL(session);
TInt err = session->InstallMtmGroup(KMtmDataFile);
test(err == KErrNone || err == KErrAlreadyExists);
CClientMtmRegistry* clientReg = CClientMtmRegistry::NewL(*session);
CleanupStack::PushL(clientReg);
CBaseMtm* client = NULL;
client = clientReg->NewMtmL(KUidTestMtm);
CleanupStack::PushL(client);
CMtmUiRegistry* uiReg = CMtmUiRegistry::NewL(*session);
CleanupStack::PushL(uiReg);
if (client !=NULL)
{
TRAPD(error, uiReg->NewMtmUiL(*client));
test(error == KErrBadLibraryEntryPoint);
}
CleanupStack::PopAndDestroy(5); // uiReg, client, clientReg, session, ob
}