⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bosswriter.cpp

📁 Symbian C++ scmp.zip
💻 CPP
字号:
// BOSSWRITER.CPP
//
// Copyright (c) 1997-2003 Symbian Ltd.  All rights reserved.
//


#include <s32file.h>
#include "bosswriter.h"
#include <apadef.h>
#include <apaid.h>

//#include "literals.h"

// UID of Boss App
const TUid KUidBossApp= { 0x10000253 } ;


void CBossWriter::ExecuteLD(const TDesC& aFileName)
	{
	CleanupStack::PushL(this);
	User::LeaveIfError(iFs.Connect());
	OpenStoreL(aFileName);
//	InitializePuzzle();
//	Draw();
	OpenRootDictionaryL();
	WriteDocumentL();
	WriteAppIdentifierL();
	WriteRootDictionaryL();
	CleanupStack::PopAndDestroy();
	}

CBossWriter::~CBossWriter()
	{
	delete iRootDictionary;
	delete iStore;
	iFs.Close();
	}

/**
	Opens the store for writing.  This function creates a direct file store.  
	But when this function has completed, only the persistent store is passed to other
	parts of the program.  Therefore this code can easily be adapted for the purposes
	of embedded documents.
*/
void CBossWriter::OpenStoreL(const TDesC& aFileName)
	{
	CFileStore* store=CDirectFileStore::CreateLC(
			iFs,aFileName,EFileWrite);


    store->SetTypeL(TUidType(KDirectFileStoreLayoutUid, KUidAppDllDoc, KUidBossApp));
	RFile file=store->File();
	CleanupStack::Pop();
	iStore=store;
	}

void CBossWriter::OpenRootDictionaryL()
	{
	iRootDictionary=CStreamDictionary::NewL();
	}

/**
	The root dictionary contains (uid, streamid) pairs identifying the app identifier 
	stream and any document head streams.  To open it, just create the stream 
	dictionary. 
    When all streams have been written, the root stream is also written out.
*/
void CBossWriter::WriteRootDictionaryL()
	{
	RStoreWriteStream root;
	TStreamId id=root.CreateLC(*iStore);
	iRootDictionary->ExternalizeL(root);
	root.CommitL();
	CleanupStack::PopAndDestroy(); // root
	iStore->SetRootL(id);
	iStore->CommitL();
	}

/**
	Just store the data. 
	Then note the uid/streamid association in the root dictionary
*/
void CBossWriter::WriteDocumentL()
	{
	TStreamId id=iPuzzle.StoreL(*iStore);
	iRootDictionary->AssignL(KUidBossApp, id);
	}

/**
	Create and store an app identifier.  
	Then note the uid/streamid association in the root dictionary
*/
void CBossWriter::WriteAppIdentifierL()
	{
	TApaAppIdentifier ident(KUidBossApp, *(&KTxtBossApp));
	RStoreWriteStream stream;
	TStreamId id=stream.CreateLC(*iStore);
	stream << ident;
	stream.CommitL();
	iRootDictionary->AssignL(KUidAppIdentifierStream, id);
	CleanupStack::PopAndDestroy(); // stream
	}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -