当前位置: 首页>>代码示例>>C++>>正文


C++ TFileText::Read方法代码示例

本文整理汇总了C++中TFileText::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileText::Read方法的具体用法?C++ TFileText::Read怎么用?C++ TFileText::Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TFileText的用法示例。


在下文中一共展示了TFileText::Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadHttpTypesFileL

void CHttpTypes::ReadHttpTypesFileL(const TDesC& aFileName)
{
	RFs fs;

#if EPOC_SDK >= 0x06000000
	User::LeaveIfError(fs.Connect());
	iHttpTypesArray = new (ELeave) CDesCArrayFlat(HTTP_TYPES_ARRAY_GRANURALITY);

	HBufC *config = NULL;
	// Need to TRAP leaves, because must close the fs (right).
	// Thus, no point in using the CleanupStack for config either.
	//
	TRAPD(err, config = UnicodeLoad::LoadL(fs, aFileName));
	if (err == KErrNone && config != NULL)
		{
		TLineBuffer buffer(config->Des());
		while (!buffer.EOB())
			{
			TPtrC line = buffer.ReadLine();
			if (line.Length() > 0)
				{
				TRAP(err, ParseTypeLineL(line));
				if (err != KErrNone)
					break;
				}
			}
		}
	delete config;
	User::LeaveIfError(err);

#else
	RFile cfg;
	TFileText cfgtxt;
	TBuf<256> buffer;

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(cfg.Open(fs,aFileName,EFileStreamText));

	iHttpTypesArray = new (ELeave) CDesCArrayFlat(HTTP_TYPES_ARRAY_GRANURALITY);
	
	cfgtxt.Set(cfg);
	User::LeaveIfError(cfgtxt.Seek(ESeekStart));
	
	cfgtxt.Read(buffer);
	while (buffer.Length() > 0)
	{
		ParseTypeLineL(buffer);
		cfgtxt.Read(buffer);
	}
	
	cfg.Close();
#endif
	iHttpTypesArray->Sort();

	fs.Close();
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:56,代码来源:ws_eng.cpp

示例2: ReadConfigFileL

void CWebServerEnv::ReadConfigFileL(const TDesC& aConfigFileName)
//Function which reads and parse the confing file
{

	RFs fs;
#if EPOC_SDK >= 0x06000000
	User::LeaveIfError(fs.Connect());
	HBufC *config = NULL;
	// Need to TRAP leaves, because must close the fs (right).
	// Thus, no point in using the CleanupStack for config either.
	//
	TRAPD(err, config = UnicodeLoad::LoadL(fs, aConfigFileName));
	if (err == KErrNone && config != NULL)
		{
		TLineBuffer buffer(config->Des());
		while (!buffer.EOB())
			{
			TPtrC line = buffer.ReadLine();
			if (line.Length() > 0)
				{
				TRAP(err, ParseConfigLineL(fs, line));
				if (err != KErrNone)
					break;
				}
			}
		}
	delete config;
	fs.Close();
	User::LeaveIfError(err);
#else
	RFile cfg;
	TFileText cfgtxt;
	TBuf<256> buffer;

	User::LeaveIfError(fs.Connect());
	User::LeaveIfError(cfg.Open(fs,aConfigFileName,EFileStreamText));
	
	cfgtxt.Set(cfg);
	User::LeaveIfError(cfgtxt.Seek(ESeekStart));
	cfgtxt.Read(buffer);
	while (buffer.Length() > 0)
	{
		ParseConfigLineL(fs,buffer);
		cfgtxt.Read(buffer);
	}
	
	cfg.Close();

	fs.Close();
#endif
	CheckAndSetDefaultL();

}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:53,代码来源:ws_eng.cpp

示例3: TestAddressStringTokenizers

void CT_AddressStringTokenizerStep::TestAddressStringTokenizers(CTulAddressStringTokenizer* aAddressStringTokenizer, TFileText& aReader, TDes& aText)
	{
    TBuf<KReadBufSize> fileBuffer;

    // Get count of found items.
    TInt count(aAddressStringTokenizer->ItemCount());
	TEST(count > 0);
	TPtrC result;

    // SFoundItem instance
    CTulAddressStringTokenizer::SFoundItem item;

    TBool found = aAddressStringTokenizer->Item(item);
    TEST(found);
    for(TInt i = 0; i < count; i++)
		{
        result.Set(aText.Mid(item.iStartPos, item.iLength));
		aReader.Read(fileBuffer);

		//Comparing parsed result to what read buffer reads from the file.
		TEST(!fileBuffer.Compare(result) );
		if (fileBuffer.Compare(result))
			{
			INFO_PRINTF2(_L("Buffer : %S"), &fileBuffer);
			INFO_PRINTF2(_L("Result : %S"), &result);
			}
        aAddressStringTokenizer->NextItem(item);
        }
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:29,代码来源:t_addressstringtokenizer.cpp

示例4: ConstructL

void CSettings::ConstructL()
{
    RFs fs;
    RFile file;
    TFileText text;
    TLex lex;
    TBuf<256> buf;
    User::LeaveIfError(fs.Connect());
    if(file.Open(fs,_L("C:\\System\\Apps\\vcall\\times"),EFileRead) != KErrNone)
    {
        User::Panic(_L("Config file not open"),KErrNotFound);
    }
    text.Set(file);
    while(text.Read(buf) == KErrNone)
    {
        lex.Assign(buf);
        TInt val;
        lex.Val(val);//TODO: error handling
        iTimes.Append(val);
    }
    file.Close();
    //iTimes.SortSigned();//TODO: fix sort
    iTimer = CVTimer::NewL();
    iTimer->setTimes(iTimes);
}
开发者ID:Seikareikou,项目名称:symbian,代码行数:25,代码来源:settings.cpp

示例5:

void CTap2MenuAppUi::ReadExceptions()
	{
	TInt err=KErrNone;
	iExceptions.Reset();
	if (BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),KExceptionsPath)) //!!!!!!!!!!!!!!!!!!!!!!!!!!!
		{
		TBuf<255> val;
		TLex conv;
		TUint32 IntVal;
		RFile filesave;
		TBuf<255> t;
		TFileText ft;
		filesave.Open(CEikonEnv::Static()->FsSession(), KExceptionsPath, EFileRead);
		ft.Set(filesave);
		while (ft.Read(val)==KErrNone)
			{
			conv.Assign(val);
			conv.Val(IntVal,EHex);
			iExceptions.AppendL(TUid::Uid(IntVal));
			}
		filesave.Close();
		}
	else
		{
		TParse parse;
		CEikonEnv::Static()->FsSession().Parse(KExceptionsPath,parse);
		if (!BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(),parse.DriveAndPath()))
			{
			CEikonEnv::Static()->FsSession().MkDirAll(parse.DriveAndPath());
			}
		}
	}
开发者ID:kolayuk,项目名称:Tap2Menu,代码行数:32,代码来源:Tap2MenuAppUi.cpp

示例6: ReadConfigFileL

// -----------------------------------------------------------------------------
// CStartupAdaptationStubModel::ReadConfigFileL
//
// -----------------------------------------------------------------------------
//
void CStartupAdaptationStubModel::ReadConfigFileL()
    {
    RDEBUG( _L( "CStartupAdaptationStubModel::ReadConfigFileL." ) );

    RFs fs;
    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL( fs );

    RFile file;
    User::LeaveIfError( file.Open( fs, KConfigFile, EFileShareReadersOnly ) );
    CleanupClosePushL( file );

    TFileText reader;
    reader.Set( file );

    TBuf<256> buf;
    TLex lex( buf );

    for ( TInt i = 0; i < KNumResponseLists; i++ )
        {
        User::LeaveIfError( reader.Read( buf ) );

        RDEBUG_1( _L( "CStartupAdaptationStubModel: Config line: %S." ), &buf );

        lex.Assign( buf );
        ReadStructuredListL(
            iResponses[ i ].iParts, lex, *( iResponses[ i ].iList ) );
        }

    CleanupStack::PopAndDestroy( 2 ); // file, fs

    RDEBUG( _L( "CStartupAdaptationStubModel::ReadConfigFileL finished." ) );
    }
开发者ID:cdaffara,项目名称:symbian-oss_adapt,代码行数:38,代码来源:StartupAdaptationStubModel.cpp

示例7: LoadPluginsL

void CCryptoPluginsLoader::LoadPluginsL()
{
    HBufC *configFileBuf = GetConfigFileNameL();
    CleanupStack::PushL(configFileBuf);
    TPtr configFile(configFileBuf->Des());

    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFile file;
    User::LeaveIfError(file.Open(fs, configFile, KEntryAttNormal));
    CleanupClosePushL(file);

    TFileText ft;
    ft.Set(file);
    TFileName line;

    User::LeaveIfError(ft.Read(line));

    //Load all the plugins
    do
    {
        TFileName filename;
        filename.Append(KPluginDir);
        filename.Append(line);

        //Load...
        RLibrary plugin;
        TInt err=plugin.Load(filename);
        if (err==KErrNone)
        {
            CleanupClosePushL(plugin);
            iPluginDllList.AppendL(plugin);
            CleanupStack::Pop(&plugin);
            iPluginNames.AppendL(line);
        }
    }
    while(ft.Read(line) == KErrNone);


    CleanupStack::PopAndDestroy(&file);
    CleanupStack::PopAndDestroy(&fs);
    CleanupStack::PopAndDestroy(configFileBuf);

    BuildPluginCharacteristicsL();
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:47,代码来源:cryptopluginsloader.cpp

示例8: LeaveIfError

 /*
  * Save Form data, function to be executed when save option is selected. 
  * Creates the second form which allows for selecting the category.
  */
 TBool CYPagesForm1::SaveFormDataL()
{  
    CAknPopupFieldText* popupFieldText = static_cast <CAknPopupFieldText*> (ControlOrNull(EYPagesPopup));
 	if (popupFieldText) {		
		TInt categoryIndex = popupFieldText->CurrentValueIndex();
		TBuf <30> KMyTextFile;
		KMyTextFile.Format(_L("D:\\YPages\\%d%d.txt"), iColor, categoryIndex);
		
		RFs fileServer;
 	    User :: LeaveIfError (fileServer.Connect());
 	    RFile file;
 	    User::LeaveIfError(file.Open(fileServer, KMyTextFile, EFileRead|EFileStreamText));
 	    CleanupClosePushL(file);
 	    
 	    TFileText fileText;
 	    fileText.Set(file);
 	    
 	    TBuf<100> buffer;
 	    buffer = _L("");

 	    RBuf rBuf;
 	    rBuf.Create(buffer);
 	    rBuf.CleanupClosePushL();
 	    
 	  
 	    TInt err = KErrNone;
 	    while(err != KErrEof) {
 			err = fileText.Read(buffer);
 	    
 			if ((err != KErrNone) && (err != KErrEof)) {
 				User :: Leave(err);
 			}
 			if (KErrNone == err) {
 				rBuf.ReAllocL(rBuf.Length() + buffer.Length()+2);
 				rBuf.Append(buffer);
 				rBuf.Append(_L("\n"));
 			}
 	    }
 	    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(rBuf);
 	    dlg->PrepareLC(R_ABOUT_HEADING_PANE);
   	    dlg->SetHeaderTextL(_L(""));  
   	    dlg->RunLD();
 	    		     
 	    CleanupStack::PopAndDestroy(&rBuf);
 	    CleanupStack::PopAndDestroy(&file);
 	    
 	    fileServer.Close();

 	
 	}

        

 	return ETrue;
 }
开发者ID:pulkit110,项目名称:Yellow-Pages-Symbian,代码行数:59,代码来源:YPagesForm1.cpp

示例9: About

void CDesktopHotKeyAppUi::About()
	{
	TFileName filename;
	GetAppPath(filename);
	HBufC* textResource = StringLoader::LoadLC(R_ABOUT_FILE);
	filename.Append(textResource->Des());
	CleanupStack::PopAndDestroy(textResource);

	RFile file;
	TInt nErr = file.Open(CEikonEnv::Static()->FsSession(), filename, EFileRead
			| EFileShareAny);
	if (nErr != KErrNone)
		return;

	TFileText fileText;
	fileText.Set(file);
	TBuf<128> linePtr;
	HBufC* iText = NULL;

	while (fileText.Read(linePtr) == KErrNone)
		{
		if (iText!=NULL)
			{
			iText = iText->ReAllocL(iText->Length() + linePtr.Length() + 2);
			iText->Des().Append(linePtr);
			}
		else
			{
			iText = HBufC::NewL(linePtr.Length() + 2);
			iText->Des().Append(linePtr);
			}
		iText->Des().Append(CEditableText::ELineBreak);
		}
	file.Close();

	ShowModalAboutDlgL(R_ABOUT_DIALOG_TITLE,iText->Des());
	
	
	delete iText;
	}
开发者ID:flaithbheartaigh,项目名称:lemonplayer,代码行数:40,代码来源:DesktopHotKeyAppUi.cpp

示例10: ReadTextL

TBool CHelpContainer::ReadTextL()
	{
	TFileName filename;
	GetAppPath(filename);
	HBufC* textResource = StringLoader::LoadLC(R_HELP_FILE);
	filename.Append(textResource->Des());
	CleanupStack::PopAndDestroy(textResource);

	RFile file;
	TInt nErr = file.Open(CEikonEnv::Static()->FsSession(), filename, EFileRead
			| EFileShareAny);
	if (nErr)
		{
		return EFalse;
		}

	TFileText fileText;
	fileText.Set(file);
	TBuf<128> linePtr;

	while (fileText.Read(linePtr) == KErrNone)
		{
		if (iText)
			{
			iText = iText->ReAllocL(iText->Length() + linePtr.Length() + 2);
			iText->Des().Append(linePtr);
			}
		else
			{
			iText = HBufC::NewL(linePtr.Length() + 2);
			iText->Des().Append(linePtr);
			}
		iText->Des().Append(CEditableText::ELineBreak);
		}
	file.Close();

	return ETrue;
	}
开发者ID:flaithbheartaigh,项目名称:lemonplayer,代码行数:38,代码来源:HelpContainer.cpp

示例11: conv

void CTap2MenuAppUi::ReadSettings()
	{
	TInt err=KErrNone;
	iSettings.Reset();
	if (BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),KSettingPath)) //!!!!!!!!!!!!!!!!!!!!!!!!!!!
		{
		TBuf<255> val;
		RFile filesave;
		TBuf<10> t;
		TFileText ft;
		TUint32 IntVal;
		filesave.Open(CEikonEnv::Static()->FsSession(), KSettingPath, EFileRead);
		ft.Set(filesave);
		while (ft.Read(val)==KErrNone)
			{
			TLex conv(val);
			conv.Val(IntVal,EDecimal);
			iSettings.Append(IntVal);
			}
		filesave.Close();
		}
	else
		{
		TParse parse;
		CEikonEnv::Static()->FsSession().Parse(KSettingPath,parse);
		if (!BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(),parse.DriveAndPath()))
			{
			CEikonEnv::Static()->FsSession().MkDirAll(parse.DriveAndPath());
			}
		iSettings.Append(KPosXP);
		iSettings.Append(KPosYP);
		iSettings.Append(KPosXL);
		iSettings.Append(KPosYL);
		iSettings.Append(KSize);
		WriteSettings();
		}
	}
开发者ID:kolayuk,项目名称:Tap2Menu,代码行数:37,代码来源:Tap2MenuAppUi.cpp

示例12: test

EXPORT_C void bases::test(COperatorMap* aOpMap, CCellMap* aCellMap)
{
	CALLSTACKITEM_N(_CL("bases"), _CL("test"));

#ifdef __WINS__ 
	aOpMap->AddRef();

	iTimer->Reset();

	testing=true; bool first=true;
	test_flags=0;
	scale=1.0; proportion=0.9;
	learning_done=false;

	RFile testf;
	TFileText test;
	int ts_len=15;
	TBuf<128> filen;
	TBuf<256> line;
	TBuf<30> id_d, dt_d;
	filen.Append(DataDir());
	filen.Append(_L("bases_test_data.txt"));

	op=Cfile_output_base::NewL(AppContext(), _L("bases"));
	Cfile_output_base& o=*op;

	CBBSensorEvent e(KCell, KCellIdTuple);
	TBBCellId cell(KCell);
	e.iData.SetValue(&cell); e.iData.SetOwnsValue(EFalse);

	if (testf.Open(Fs(), filen, 
		EFileShareAny | EFileStreamText | EFileRead)==KErrNone) {
		CleanupClosePushL(testf);
		test.Set(testf);
		int j=0;
	

		//int beg=23000, end=230000;
		int beg=0, end=0;

		while ( test.Read(line) == KErrNone && j < end) {
		//for (int i=0;i<TEST_DATA_COUNT; i++) {
			if (! (j % 1000) ) {
				TBuf<40> msg;
				msg.Format(_L("Testing at %d"), j);
				RDebug::Print(msg);
			}
			j++;
			if (j>=beg) {
				dt_d=line.Left(ts_len);
				id_d=line.Mid(ts_len+1);
				
				TTime time(dt_d);
				now=time;
				if (first) { 
					previous_time=now; first_time=now; first=false; 
					previous_day=previous_time;
				}
				if (! id_d.Compare(_L("SWITCH"))) {
					started=true;
				} else {
					e.iStamp()=time;
					CCellMap::Parse(id_d, cell.iCellId(), cell.iLocationAreaCode(), cell.iShortName());
					if (cell.iCellId()==0 && cell.iLocationAreaCode()==0) {
						cell.iMCC()=0;
						cell.iMNC()=0;
					} else {
						aOpMap->NameToMccMnc(cell.iShortName(), cell.iMCC(),
 cell.iMNC());
					}
					cell.iMappedId()=aCellMap->GetId(cell);
					NewSensorEventL(KNoTuple, KNullDesC, e); // name is ignored
				}
			}
		}
		CleanupStack::PopAndDestroy(); // testf
	}

	e.iData.SetValue(0);

	if (! (test_flags & NO_DB_UPDATE) ) {
		read_from_database(false, 0);
	}

	line.Format(_L("total %f\n"), total_t);
	o.write_to_output(line);
	cell_list_node* n=first_cell;
	while (n) {
		TInt base=0;
		if (n->is_base) base=1;
		line.Format(_L("%d: t %f f %d cum_t %f base %d merged to %d\n"),
			n->id, n->t, n->f, n->cum_t, base, n->merged_to);
		o.write_to_output(line);
		n=n->next;
	}

	o.write_to_output(_L("MAPPINGS:\n"));
	aCellMap->PrintMapping(o);

	delete op;
//.........这里部分代码省略.........
开发者ID:flaithbheartaigh,项目名称:jaikuengine-mobile-client,代码行数:101,代码来源:bases.cpp

示例13: ParseURIFileL

/**
   @SYMTestCaseID UIF-ETUL-0009

   @SYMREQ 7736
 
   @SYMTestCaseDesc Test to Parse for URI's, Email Addresses, Phone Numbers and URL's in a file and to verify them
  
   @SYMTestPriority High 
 
   @SYMTestStatus Implemented
  
   @SYMTestActions Constructs CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin \n
   which parses the given string and creates an item array consisting of all the Email addresses\n
   API Calls:\n	
   CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n
   CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n
   CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n   
  
   @SYMTestExpectedResults The test checks whether 
   1. Phone numbers, Email addresses, URL's and URI's  parsed by CTulAddressStringTokenizer are the correct ones.
 */
void CT_AddressStringTokenizerStep::ParseURIFileL()
    {
	INFO_PRINTF1(_L("Test begins"));
    __UHEAP_MARK;

    //load test case text to string
    RFs rfs;
    User::LeaveIfError(rfs.Connect());
    CleanupClosePushL(rfs);
 	_LIT(KParesTextFile, "z:\\system\\data\\addressstringtokenizertestappdata.txt");
	_LIT(KParesTextFileRef, "z:\\system\\data\\addressstringtokenizertestappdataref.txt");

    RFile file;
    HBufC* fullBuf = HBufC::NewMaxLC(KFullBufSize);
    TPtr fullBufPtr = fullBuf->Des();                  
    fullBufPtr = KNullDesC;

	TFileText reader;
    TBuf<KReadBufSize> fileBuffer;

	if ((file.Open(rfs, KParesTextFile, EFileStreamText|EFileRead|EFileShareAny)) == KErrNone)
		{
		CleanupClosePushL(file);
        // use TFileText for reading file. There is probably better ways to do this tho.
        reader.Set(file);
        if (reader.Seek(ESeekStart))
			{
			INFO_PRINTF1(_L("File corrupted"));
            User::Leave(KErrGeneral); // not cleaning up properly
            }

        while (!reader.Read(fileBuffer))
		    {
		    fullBufPtr.Append(fileBuffer);
		    fullBufPtr.Append('\n');   
		    }
		CleanupStack::Pop(&file);    
        file.Close();
        }
    else
        {
		INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdata.txt not found"));
		User::Leave(KErrNotFound);
  	   }

	if (file.Open(rfs, KParesTextFileRef, EFileStreamText|EFileRead|EFileShareAny) == KErrNone)
		{
		CleanupClosePushL(file);
        // use TFileText for reading file. There is probably better way to do this tho.
        reader.Set(file);
        if (reader.Seek(ESeekStart))
			{
			INFO_PRINTF1(_L("File corrupted"));
            User::Leave(KErrGeneral); // not cleaning up properly
            }
		}
    else
        {
		INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdataref.txt not found"));
		User::Leave(KErrNotFound);
        }

    INFO_PRINTF1(_L("Start searching..."));
                
    // Create an instance of Address String Tokenizer and search for URL's.
    CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchURLBin);
    TestAddressStringTokenizers(addressString, reader, fullBufPtr);
    delete addressString;

    // find phone numbers from same text
    addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin);
    TestAddressStringTokenizers(addressString, reader, fullBufPtr);
	
    // test do new search with same instance
    TInt count = addressString->DoNewSearchL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin);
  	TEST(count > 0);
  	TestAddressStringTokenizers(addressString, reader, fullBufPtr);
    delete addressString;
                
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:101,代码来源:t_addressstringtokenizer.cpp

示例14: GetSectionData

EXPORT_C TInt TEFparser::GetSectionData(TDesC& aScriptFilepath, TPtrC& aSectiontag, TDesC16 &aTocspTestFile, RFs& aFs)
	{
	
	TInt err = KErrNone;	
	TInt pos = 0;
	RFile file;
	
	// open the .ini file
	if (BaflUtils::FolderExists(aFs, aScriptFilepath))
		{		
		if (BaflUtils::FileExists( aFs, aScriptFilepath ))
			{	
			file.Open(aFs, aScriptFilepath, EFileRead | EFileShareAny);
			
			TFileText aLineReader;
			TBuf<256> iLine;
			TBuf<256> tempsectID;

			// create the section name to search for
			tempsectID.Copy(KOpenBrk);
			tempsectID.Append(aSectiontag);
			tempsectID.Append(KCloseBrk);
			
			// read the ini file a line at a time until you find the the section name
			aLineReader.Set(file);		
			TInt foundTag = -1;
			while (err != KErrEof && foundTag != 0)
				{
				err = aLineReader.Read(iLine);
				if (err != KErrEof)
					foundTag =  iLine.Find(tempsectID);
				}
			
			// create the next open bracket to search for		
			TBuf<2> tempopenBrk;
			tempopenBrk.Copy(KOpenBrk);
			
			RFile testfile;	
			err = KErrNone;
			foundTag = -1;

			// while not at the end of the file and not found the next open bracket
			while (err != KErrEof && foundTag != 0)
				{

				// get the next line of the .ini file
				err = aLineReader.Read(iLine);
				if (err != KErrEof)
					{

					// if the line of the file doesn't contain an open bracket, we are still in the section body
					foundTag =  iLine.Find(tempopenBrk);
					if (BaflUtils::FolderExists(aFs, aTocspTestFile) && foundTag != 0)
						{		
						// open the test file we are going to write all our section info into
						if (BaflUtils::FileExists( aFs, aTocspTestFile ))
							{	
							testfile.Open(aFs, aTocspTestFile, EFileWrite|EFileShareAny);
							testfile.Seek(ESeekEnd, pos);
							}
						else
							{	
							User::LeaveIfError(testfile.Create(aFs, aTocspTestFile, EFileWrite|EFileShareAny));
							testfile.Open(aFs, aTocspTestFile, EFileWrite|EFileShareAny);
							}
						// append to line of the file end of line characters
						iLine.Append(_L("\r\n"));

						// write line of the code out to the test file in UNICODE format 
						TPtrC8 tmpPoint((TText8*)iLine.Ptr(),iLine.Size());
						testfile.Write(tmpPoint); 
						
						testfile.Flush();							
						}
					testfile.Close();
					}
				}
			}
		}
		return KErrNone;

	}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:82,代码来源:TEFparser.cpp

示例15: pj_symbianos_get_model_info

PJ_END_DECL


/* Get Symbian phone model info, returning length of model info */
unsigned pj_symbianos_get_model_info(char *buf, unsigned buf_size)
{
    pj_str_t model_name;

    /* Get machine UID */
    TInt hal_val;
    HAL::Get(HAL::EMachineUid, hal_val);
    pj_ansi_snprintf(buf, buf_size, "0x%08X", hal_val);
    pj_strset2(&model_name, buf);

    /* Get model name */
    const pj_str_t st_copyright = {"(C)", 3};
    const pj_str_t st_nokia = {"Nokia", 5};
    char tmp_buf[64];
    pj_str_t tmp_str;

    _LIT(KModelFilename,"Z:\\resource\\versions\\model.txt");
    RFile file;
    RFs fs;
    TInt err;
    
    fs.Connect(1);
    err = file.Open(fs, KModelFilename, EFileRead);
    if (err == KErrNone) {
	TFileText text;
	text.Set(file);
	TBuf16<64> ModelName16;
	err = text.Read(ModelName16);
	if (err == KErrNone) {
	    TPtr8 ptr8((TUint8*)tmp_buf, sizeof(tmp_buf));
	    ptr8.Copy(ModelName16);
	    pj_strset(&tmp_str, tmp_buf, ptr8.Length());
	    pj_strtrim(&tmp_str);
	}
	file.Close();
    }
    fs.Close();
    if (err != KErrNone)
	goto on_return;
    
    /* The retrieved model name is usually in long format, e.g: 
     * "© Nokia N95 (01.01)", "(C) Nokia E52". As we need only
     * the short version, let's clean it up.
     */
    
    /* Remove preceding non-ASCII chars, e.g: "©" */
    char *p = tmp_str.ptr;
    while (!pj_isascii(*p)) { p++; }
    pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
    
    /* Remove "(C)" */
    p = pj_stristr(&tmp_str, &st_copyright);
    if (p) {
	p += st_copyright.slen;
	pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
    }

    /* Remove "Nokia" */
    p = pj_stristr(&tmp_str, &st_nokia);
    if (p) {
	p += st_nokia.slen;
	pj_strset(&tmp_str, p, tmp_str.slen - (p - tmp_str.ptr));
    }
    
    /* Remove language version, e.g: "(01.01)" */
    p = pj_strchr(&tmp_str, '(');
    if (p) {
	tmp_str.slen = p - tmp_str.ptr;
    }
    
    pj_strtrim(&tmp_str);
    
    if (tmp_str.slen == 0)
	goto on_return;
    
    if ((unsigned)tmp_str.slen > buf_size - model_name.slen - 3)
	tmp_str.slen = buf_size - model_name.slen - 3;
    
    pj_strcat2(&model_name, "(");
    pj_strcat(&model_name, &tmp_str);
    pj_strcat2(&model_name, ")");
    
    /* Zero terminate */
    buf[model_name.slen] = '\0';
    
on_return:
    return model_name.slen;
}
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:92,代码来源:os_info_symbian.cpp


注:本文中的TFileText::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。