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


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

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


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

示例1: SaveL

TInt CSpecialLog::SaveL(void)
{
	// Open file.
	TFileName filename;
	filename.Copy(KSpecialLogPath);
	filename.Append(KSpecialLogFile);
	RFile file;
	TInt result = file.Replace(* iFs, filename, EFileWrite);
	if (KErrNone != result)
	{
		return result;
	}

	// Write file
	TFileText fileText;
	fileText.Set(file);
	HBufC* buffer = HBufC::NewLC(KSpecialLogLineBufferSize);
	TPtr line = buffer->Des();

	line.Copy(KSpecialLogSection);					// Write section header.
	fileText.Write(line);

	for (TInt i = 0; i < iLogSpecial.Count(); i ++)	// Write all special log entries.
	{
		const RLogSpecial & entry = iLogSpecial[i];
		// Write key (text if defined, otherwise index)
		if (i < KNumSpecialLogKeys)
			line.Copy((const TUint16 *) KSpecialLogKeyText[i]);	// TODO: Fix the cast.
		else
			line.Num(i);

		line.Append(_L("="));
		// Write value.
		if (ESpecialLogInt == entry.iType)
			line.AppendNum(entry.iInt);
		else
			line.Append(* entry.iText);

		result = fileText.Write(line);
		if (result != KErrNone)
			break;
	}
	CleanupStack::PopAndDestroy(buffer);
	file.Close();

	if (KErrEof == result) result = KErrNone;

	iState = ESaved;

	// Bubble result of TFileText::Write().
	return result;
}
开发者ID:yindian,项目名称:fontrouter,代码行数:52,代码来源:DebugHelper.cpp

示例2: ShowL

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void CPixelMetricsMapperViewContainer::ShowL( const TDesC& aString, TBool& aLast, const TBool& aFileOutput )
    {
    MDesCArray* itemList = iListbox->Model()->ItemTextArray();
    CDesCArray* itemArray = ( CDesCArray* ) itemList;

    itemArray->AppendL( aString );

    iListbox->HandleItemAdditionL();
    iListbox->SetCurrentItemIndex( iCount );
    iCount++;
    if ( aLast )
        {
        if (aFileOutput)
            {
            RFile file;
            RFs& fs = CEikonEnv::Static()->FsSession();
            TFileName fileName =_L("Layout_");

            TRect screenRect;
            AknLayoutUtils::LayoutMetricsRect(
                AknLayoutUtils::EApplicationWindow,
                screenRect );

            // Add screen dimensions
            TInt height = screenRect.Height();
            TInt width = screenRect.Width();
            fileName.AppendNum(height);
            fileName.Append('_');
            fileName.AppendNum(width);

            fileName.Append(_L(".txt"));

            TInt err=file.Open(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny);
            if (err==KErrNotFound) // file does not exist - create it
                err=file.Create(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny);
            else
                file.SetSize(0); //sweep the file
            TFileText textFile;
            textFile.Set(file);
            err = textFile.Seek(ESeekStart);
            if (err) User::InfoPrint(_L("File corrupted"));

            // Finally loop through all the entries:
            TInt idx = 0;
            for(;idx!=itemList->MdcaCount();idx++)
                {
                err = textFile.Write(itemList->MdcaPoint(idx));
                if (err) User::InfoPrint(_L("File corrupted"));
                }
            file.Close();
            }
        DrawNow();
        }
    }
开发者ID:mpvader,项目名称:qt,代码行数:58,代码来源:pm_mapperview.cpp

示例3: LocationRequestThread

/**
 * This is the main function for threads that connects and
 * disconnect from MLFW
 *
 * Function returns 0 if running of the test did not leave.
 *Otherwise the leave code is returned.
 **/
LOCAL_C TInt LocationRequestThread(TAny* aData)
{
    // Create cleanupstack for this thread
    CTrapCleanup* cleanup = CTrapCleanup::New();

    // No parameters to read, just start main function.

    HBufC* buf = HBufC::NewL(1024);

    TPtr ptr = buf->Des();

    // Run the actual test, and trap possible leave
    TRAPD(leave, LocationRequestThreadMainPartL(ptr));

    // Open connection to file server
    RFs fs;
    User::LeaveIfError(fs.Connect());

    TInt index = *((TInt*) aData);

    TBuf<30> errorFile;
    _LIT(KInfThread, "c:\\logs\\thread%derrinfo.txt");
    errorFile.Format(KInfThread, index);

    // Open log file
    RFile file;

    TInt err = file.Replace(fs,errorFile,EFileStreamText|EFileWrite);

    if (err != KErrNone)
        {
        User::Leave(err);
        }

    _LIT(KErrLeave, "*** This thread (thread %d) leave code: %d\r\n");
    ptr.AppendFormat(KErrLeave, index, leave);

    TFileText fileText;
    fileText.Set(file);

    fileText.Write(ptr);

    // Close log file
    file.Close();
    fs.Close();

    // Delete cleanup stack
    delete cleanup;

    // Exit this thread with leave code (KErrNone in successful case)
    User::Exit(leave);

    return 0;
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:61,代码来源:ctlbsclientpostp208.cpp

示例4: CallTestsQL

GLDEF_C void CallTestsQL(TInt aDrive)
//
// Call tests for remote drive
//
	{

	Test0(testq);
	
	testq.Printf(_L("This may take some time.  Please be patient...\n"));
	
	testq.Next(_L("Test remote drive with multiple sessions"));
	MultipleSessions(aDrive,testq);

	const TInt numberOfTests=10;
	
	TPtrC record[numberOfTests];
	
	TInt i=0;
	for (;i<numberOfTests;i++)
		{
		if (i%2)
			record[i].Set(_L("Hubble_Bubble"));
		else
			record[i].Set(_L("Toil_and_Trouble"));
		}
	
	testq.Next(_L("Create a file 'TEXTFILE.TXT' on the remote drive"));
	RFile f;
	TInt r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0);
	testq(r==KErrNone);
	TFileText textFile;
	textFile.Set(f);
	
	testq.Next(_L("Write to 'TEXTFILE.TXT'"));
	
	for (i=0;i<numberOfTests;i++)
		{
		r=textFile.Write(record[i]);
		testq(r==KErrNone);
		testq.Printf(_L("Write %d completed OK\n"),i+1);
		}
	
	f.Close();

	RFile file1;
	r=file1.Open(TheFs,_L("Q:\\TEST\\T_FSRV.CPP"),EFileRead|EFileShareReadersOnly);
	testq(r==KErrNone);
	file1.Close();	

	}
开发者ID:SymbianSource,项目名称:oss.FCL.interim.QEMU,代码行数:50,代码来源:svphost.cpp

示例5:

void CTap2MenuAppUi::WriteSettings()
	{
		RFs iFS=CEikonEnv::Static()->FsSession();
		RFile filesave;
		TInt err1=filesave.Replace(iFS, KSettingPath, EFileWrite);
		TFileText ft;
		ft.Set(filesave);
		TBuf<255> temp;
		for (TInt i=0;i<iSettings.Count();i++)
			{
			temp.Num(iSettings[i],EDecimal);
			ft.Write(temp);
			}
		filesave.Close();
	}
开发者ID:kolayuk,项目名称:Tap2Menu,代码行数:15,代码来源:Tap2MenuAppUi.cpp

示例6: LogIt

void TTimerLogger::LogIt(const TDesC& aComment)
	{
	TInt err = iFs.Connect();
	if(err == KErrNone)
		{
		iFs.MkDirAll(KFilePath);
		err = iFile.Open(iFs, KFileName, EFileWrite);
		if(err == KErrNotFound)
			{
			iFile.Create(iFs, KFileName, EFileWrite);
			iFile.Write(KTestHeader);
			iFile.Write(KTestLogs);
			}
		TFileText file;
	    file.Set(iFile);
		file.Write(aComment);
		iFile.Close();
		iFs.Close();
		}
	else	
		{
		User::InfoPrint(_L("Cannot write to file"));
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:24,代码来源:TimerLogger.cpp

示例7: CreateHeaderFileL

void CPixelMetricsMapperAppUi::CreateHeaderFileL() const
    {
    // Open/create resulting file.
    RFile file;
    HBufC* layoutFile = HBufC::NewLC( KMaxFileName );
    *layoutFile = KLayoutSourceFileAndPath;
    TFileName fileName = *layoutFile;
    CleanupStack::PopAndDestroy(layoutFile);
    RFs& fs = CEikonEnv::Static()->FsSession();
    TInt error = file.Open(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText );
    if (error==KErrNotFound)
        {
       file.Create(fs,fileName, EFileWrite|EFileShareAny|EFileStreamText);
        }
    CleanupClosePushL( file );
    file.SetSize( 0 );

    // Make all writes as from textfile.
    TFileText textFile;
    textFile.Set( file );
    textFile.Seek( ESeekStart );

    // Take all layout files from private folder.
    CDir* dirList;
    User::LeaveIfError(fs.GetDir(
        KPixelMetricsDataFiles,
        KEntryAttMaskSupported,
        ESortByName,
        dirList));

    TMySmallBuffer bufferLayoutHdr;
    TMyBigBuffer bufferPMData;
    TInt fileCount = dirList->Count();
    for (TInt i=0;i<fileCount;i++)
        {
        // open sourcefile
        RFile sourceFile;
        TFileName layoutFile = (*dirList)[i].iName;
        User::LeaveIfError( sourceFile.Open(
            fs,layoutFile, EFileRead|EFileShareAny|EFileStreamText ));
        CleanupClosePushL( sourceFile );

        // Make all reads as from textfile.
        TFileText textSourceFile;
        textSourceFile.Set( sourceFile );
        TFileName layoutName = CreateLayoutNameL( textSourceFile );

        // rewind - just in case.
        textSourceFile.Seek( ESeekStart );
        TFileName oneline;
        bufferLayoutHdr.Append(KOpenBrace);
        bufferPMData.Append(KOpenBrace);
        TInt loop = 0;
        FOREVER
            {
            if( textSourceFile.Read(oneline) != KErrNone )
                {
                break;
                }
            // Add commas for all but first line
            if (loop != 0)
                {
                if ( loop <= KHeaderValues-1)
                    {
                    bufferLayoutHdr.Append(KComma);
                    }
                else
                    {
                    if (loop != KHeaderValues)
                        {
                        bufferPMData.Append(KComma);
                        }
                    }
                if (loop==KHeaderValues)
                    {
                    bufferLayoutHdr.Append(_L(",QLatin1String(\""));
                    bufferLayoutHdr.Append(layoutName);
                    bufferLayoutHdr.Append(_L("\")"));
                    }
                }
            // Remove pixel metrics name and ":"
            oneline = oneline.Mid(oneline.Find(KColon)+1);
            // Remove tab
            oneline = oneline.Mid(oneline.Find(KTab)+1);
            // remove crap from the end of line
            TLex lex(oneline);
            TInt nextValue = -666;
            User::LeaveIfError( lex.Val(nextValue) );
            if ( loop <= KHeaderValues-1)
                {
                bufferLayoutHdr.AppendNum(nextValue);
                }
            else
                {
                if (nextValue == -909)
                    bufferPMData.Append(_L("ECommonStyleValue"));
                else
                    bufferPMData.AppendNum(nextValue);
                }
            oneline.Zero();
//.........这里部分代码省略.........
开发者ID:mpvader,项目名称:qt,代码行数:101,代码来源:pm_mapperapp.cpp

示例8: ReadConf

void CMyServer::ReadConf()
    {
    __LOGSTR("ReadConf");
    if(iFile.Open(iFs,KFileConfig,EFileRead) != KErrNone)
	{//file not exist
    __LOGSTR("File not exist");
	TInt err = iFs.MkDirAll(KFileConfigDir);
	__LOGSTR1("Mkdir: %d",err);
	iFile.Replace(iFs,KFileConfig,EFileRead|EFileWrite);
	TFileText text;
	iFile.Write(0,_L8("\xff\xfe"));//signature
	text.Set(iFile);
	text.Write(_L("140"));//iX
	text.Write(_L("190"));//iY
	text.Write(_L("120"));//iLandY
	text.Write(_L("150"));//iLandX
	text.Write(_L("15"));//iHeight
	text.Write(_L("0xffffff"));//TRgb white

	text.Write(_L("0x102750f0"));//default UID
	iFile.Close();
	ReadConf();
	}else{
	__LOGSTR("File exist");
	//file exist
	TFileText text;
	TLex lex;
	TBuf<32> buf;
	text.Set(iFile);
	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iX);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iY);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iLandY);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iLandX);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iHeight);

	text.Read(buf);
	if(buf.Left(2)==_L("0x"))
		buf.Delete(0,2);
	lex.Assign(buf);
	TUint32 rgb;
	lex.Val(rgb,EHex);
	iConfig.iColor = rgb;

	text.Read(buf);
	buf.Delete(0,2); // delete 0x
	lex.Assign(buf);
	TUint tempuid;
	lex.Val(tempuid,EHex);
	iConfig.iUid.iUid = tempuid;

	iFile.Close();
	}
    }
开发者ID:Seikareikou,项目名称:symbian,代码行数:67,代码来源:server.cpp


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