本文整理汇总了C++中TFileText::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ TFileText::Set方法的具体用法?C++ TFileText::Set怎么用?C++ TFileText::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFileText
的用法示例。
在下文中一共展示了TFileText::Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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());
}
}
}
示例2: 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);
}
示例3: 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." ) );
}
示例4: 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();
}
示例5: 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;
}
示例6: 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;
}
示例7: 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();
}
}
示例8: 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();
}
示例9: 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;
}
示例10: 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();
}
示例11: 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();
}
示例12: 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;
}
示例13: 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;
}
示例14: 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();
}
}
示例15: 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"));
}
}