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


C++ TDesC::LocateF方法代码示例

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


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

示例1: ConstructL

void CRefTestAgentImportFile::ConstructL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName)
	{
	TPtrC suggestedFileName(aSuggestedFileName);	
	TPtrC outputDirectory(aOutputDirectory);
	
	// make sure any suggested extension is removed
	// otherwise our recognizer won't work
	TInt pos = aSuggestedFileName.LocateF(TChar(KExtDelimiter));
	if(pos != KErrNotFound)
		{
		// set the length so the extension is not included
		suggestedFileName.Set(aSuggestedFileName.Left(pos));
		}

	// If no output directory is suggested default to "c:\\" 
	if(outputDirectory.Length() == 0)
		{
		outputDirectory.Set(KRtaDefaultOutputDirectory());
		}

	// If no file name is suggested default to "output" 
	if(suggestedFileName.Length() == 0)
		{
		suggestedFileName.Set(KRtaDefaultOutputFile());
		}
	
	//Only files containing rights, post-acquisition rights or postacquisition content need to be imported
	if(!aMimeType.CompareF(KRtaMimeRights()) || !aMimeType.CompareF(KRtaMimeContentRights()))
		{// Files containing rights
		iMimeType = ReferenceTestAgent::EMimeContentOrRights;
		}
	else if(!aMimeType.CompareF(KRtaMimePostAcquisitionRights()))
		{// Files containing post-acquisition rights
		iMimeType = ReferenceTestAgent::EMimePostAcquisitionRights;
		}
	else if(!aMimeType.CompareF(KRtaMimePostAcquisitionContent()))
		{// Files containing post-acquisition content
		iMimeType = ReferenceTestAgent::EMimePostAcquisitionContent;
		}
	else
		{//Others are not supported
		User::Leave(KErrCANotSupported);
		}

	// create buffer to store the output directory supplied by the client
	// Append a trailing slash if there is no slash present
	iOutputDirectory = HBufC::NewL(outputDirectory.Length() + 1);
	iOutputDirectory->Des().Copy(outputDirectory);
	if(outputDirectory[outputDirectory.Length() - 1] != KPathDelimiter)
		{
		iOutputDirectory->Des().Append(TChar(KPathDelimiter));
		}
	
	// Create suggested file name by combining output directory and suggested name
	// Use the length of KRtaExtensionContentRights since it is the longest one
	iSuggestedFileName = HBufC::NewL(iOutputDirectory->Des().Length() + suggestedFileName.Length() + KRtaExtensionContentRights().Length());
	iSuggestedFileName->Des().Copy(*iOutputDirectory);
	iSuggestedFileName->Des().Append(suggestedFileName);
	switch(iMimeType)
	{
	case ReferenceTestAgent::EMimeContentOrRights:
	case ReferenceTestAgent::EMimePostAcquisitionContent:
		iSuggestedFileName->Des().Append(KRtaExtensionContent());
		break;
	case ReferenceTestAgent::EMimePostAcquisitionRights:
		iSuggestedFileName->Des().Append(KRtaExtensionPostAcquisitionRights());
	};

	// Create a file handle
	User::LeaveIfError(iFs.Connect());
	
	// create importer object
	if (iAgentCreatesOutputFiles)
		{
		iImporter = ReferenceTestAgent::CRefTestAgentImport::NewL(*iSuggestedFileName, iFs, iMimeType);
		}
	else
		{
		iImporter = ReferenceTestAgent::CRefTestAgentImport::NewL(KNullDesC, iFs, iMimeType);
		}
	
	if(iMimeType == ReferenceTestAgent::EMimePostAcquisitionContent)
		{
		//In the post-acquisition case, the rights object is installed separately and the content
		//comes without a content-xml file. It means that there is no way to extract the Content Id.
		//Therefore, the Content Id is sent as a meta-data while importing a post-acquisition content. cid=<content_id>
		iImporter->SetMetaDataL(aMetaDataArray);
		}
		
	DumpMetaData(aMetaDataArray);
	
	// create input data log
	RFile inputDataFile;
	inputDataFile.Replace(iFs, KInputDataLogFile(), EFileWrite | EFileStream);
	inputDataFile.Close();
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:96,代码来源:Reftestagentimportfile.cpp


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