void CTangImageDataWriter::SaveDataToFile(const TDesC& aFileName) { GenerateElementsData(); int pos = aFileName.LocateReverse( '\\'); if (pos!=KErrNotFound) { TPtrC dirName = aFileName.Left(pos+1); CCoeEnv::Static()->FsSession().MkDirAll(dirName); } RFile file; TInt err = file.Replace(CCoeEnv::Static()->FsSession(), aFileName, EFileWrite); CleanupClosePushL(file); if (KErrNone != err) { CleanupStack::PopAndDestroy(1); // file return; } RFileWriteStream outputFileStream(file); CleanupClosePushL(outputFileStream); outputFileStream.WriteL(iRequestXml->Des()); CleanupStack::PopAndDestroy(2); // outputFileStream, file }
TInt CFileOperate::WriteFileL(const TDesC& aFileName) { int pos = aFileName.LocateReverse( '\\'); if (pos!=KErrNotFound) { TPtrC dirName = aFileName.Left(pos+1); CCoeEnv::Static()->FsSession().MkDirAll(dirName); } RFile file; TInt err = file.Replace(CCoeEnv::Static()->FsSession(), aFileName, EFileWrite); CleanupClosePushL(file); if (KErrNone != err) { CleanupStack::PopAndDestroy(1); // file return err; } RFileWriteStream outputFileStream(file); CleanupClosePushL(outputFileStream); iNotifier->FileWriteData(outputFileStream); CleanupStack::PopAndDestroy(2); // outputFileStream, file return KErrNone; }
void GetExtNameFromFileName(const TDesC& aFileName, TDes& aExtName) { TInt order = aFileName.LocateReverse('.'); TInt sourceLength = aFileName.Length() - order -1; aExtName = aFileName.Mid(order +1, sourceLength); aExtName.LowerCase(); }
void CDebugLogPrint::WriteToLogL(const TDesC &aDes, const TDesC &aDes2) { TBuf<256> buf; TInt pos=aDes.LocateReverse(' '); if (pos<0) pos=0; buf.Copy(aDes.Mid(pos)); buf.Append(' '); buf.Append(aDes2); _LIT(KDebugFormatString, "%S"); RDebug::Print(KDebugFormatString, &buf); }
// ----------------------------------------------------------------------------- void CFileLogger::ConstructL(const TDesC &logFileName, EWriteFileMode aMode) { iFileName.Copy(logFileName); iMode = aMode; int pos = logFileName.LocateReverse( '\\'); TPtrC dirName = logFileName.Left(pos+1); User::LeaveIfError(iFsSession.Connect()); iFsSession.MkDirAll(dirName); if (iMode == KModeAlwayOpen) { OpenFile(); } }
EXPORT_C TInt TEFparser::GetiniPath( TDesC& aBuf, const TDesC& aScriptPath, TDes& aIniFilePath) { TInt err = KErrNone; TInt endPos = aScriptPath.LocateReverse('\\'); if (endPos == KErrNotFound) { err = KErrNotFound; } else { aIniFilePath.Copy(aBuf); aIniFilePath.Insert(0, aScriptPath.Left(endPos+1)); } return err; }
void GetFilePathByName(const TDesC& aFileName, TDes& aFilePath) { TInt filePathLength = aFileName.LocateReverse('\\') + 1; aFilePath = aFileName.Mid(0, filePathLength); }
//从文件路径拆分出文件名 void GetFileNameByUrl(const TDesC& aUrl, TDes& aFileName) { TInt order = aUrl.LocateReverse('/'); TInt sourceLength = aUrl.Length() - order -1; aFileName = aUrl.Mid(order + 1, sourceLength); }