WEB开发网
开发学院手机开发Symbian 开发 Symbian 读写 INI 配置文件的方法 阅读

Symbian 读写 INI 配置文件的方法

 2010-04-20 16:06:00 来源:WEB开发网   
核心提示://open fileRFile file;TUint shareMode=EFileRead | EFileWrite ;file.Open( fs, filename,shareMode ) ;TInt fileSize=0;file.Size(fileSize); //ȡ???ļ???СCnv

//open file

RFile file;

TUint shareMode=EFileRead | EFileWrite ;

file.Open( fs, filename,shareMode ) ;

TInt fileSize=0;

file.Size(fileSize); //ȡ???ļ???С

CnvUtfConverter *cutf=new (ELeave) CnvUtfConverter;

HBufC8 *bufc = HBufC8::NewL(fileSize+1);

TPtr8 ptr8(bufc->Des());

file.Read(ptr8);

//LogToFile(_L(“c:\cbm\rsadebug.txt”), bufc->Des());//

TInt res;

TPtrC8 iCursor(bufc->Des());

TBuf<256> buf16;

//TBuf8<2> bufPage;

//bufPage.Format(_L8(“%02d”), res);

//LogToFile(_L(“c:\cbm\rsadebug.txt”), bufPage);

while( ( res = iCursor.FindF(KCRLF) ) >= 0 ) {

res = iCursor.FindF(KCRLF);

TPtrC8 result = iCursor.Left(res);

iCursor.Set(iCursor.Right(iCursor.Length() ? (res +2)));

buf16.Zero();

buf16=cutf->ConvertToUnicodeFromUtf8L(result)->Des();

lines.AppendL(buf16);

}

if(iCursor.Size()>0) {

buf16.Zero();

buf16=cutf->ConvertToUnicodeFromUtf8L(iCursor)->Des();

lines.AppendL(buf16);

}

delete cutf;

delete bufc;

file.Close();

}

fs.Close();

}

void CFile::GetLinesFromFile(const TDesC& filename,CDesC8Array& lines){

RFs fs;

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

if( BaflUtils::FileExists(fs,filename) ){

//open file

RFile file;

TUint shareMode=EFileRead | EFileWrite ;

file.Open( fs, filename,shareMode ) ;

TInt fileSize=0;

file.Size(fileSize);

CnvUtfConverter *cutf=new (ELeave) CnvUtfConverter;

HBufC8 *bufc = HBufC8::NewL(fileSize+1);

TPtr8 ptr8(bufc->Des());

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:Symbian 读写 INI

编辑录入:coldstar [复制链接] [打 印]
赞助商链接