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


C++ TFileName::Left方法代码示例

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


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

示例1: WriteFavToFile

void CRuleManager::WriteFavToFile()
	{
	TFileName filename;
	GetAppPath(filename);
	filename.Append(KFavRuleFile);
	
	int pos = filename.LocateReverse('\\');
	if (pos != KErrNotFound)
		{
		TPtrC dirName = filename.Left(pos + 1);
		CCoeEnv::Static()->FsSession().MkDirAll(dirName);
		}

	RFile file;
	TInt err;

	err = file.Replace(CCoeEnv::Static()->FsSession(), filename,
			EFileWrite);
	if (KErrNone != err)
		{
		return;
		}
	CleanupClosePushL(file);	

	WriteToFile(file,iFavRule);
	TBuf8<4> num;
	num.AppendNum(iFavRule->GetFavCount());
	file.Write(num);

	CleanupStack::PopAndDestroy(); // file	
	}
开发者ID:flaithbheartaigh,项目名称:lemonplayer,代码行数:31,代码来源:RuleManager.cpp

示例2: WriteToFile

void CRuleManager::WriteToFile(RPointerArray<CRule>* aRules)
	{
	TFileName filename;
	GetAppPath(filename);
	filename.Append(KRuleFile);
	
	int pos = filename.LocateReverse('\\');
	if (pos != KErrNotFound)
		{
		TPtrC dirName = filename.Left(pos + 1);
		CCoeEnv::Static()->FsSession().MkDirAll(dirName);
		}

	RFile file;
	TInt err;

	err = file.Replace(CCoeEnv::Static()->FsSession(), filename,
			EFileWrite);
	if (KErrNone != err)
		{
		return;
		}
	CleanupClosePushL(file);
	
	for(TInt i=0; i<aRules->Count(); i++)
		{
		CRule* rule = (*aRules)[i];
		WriteToFile(file,rule);
		}

	CleanupStack::PopAndDestroy(); // file	
	}
开发者ID:flaithbheartaigh,项目名称:lemonplayer,代码行数:32,代码来源:RuleManager.cpp

示例3: SetDefaultParentObjectL

/**
Get a default parent object, ff the request does not specify a parent object, 
*/
void CMTPImageDpCopyObject::SetDefaultParentObjectL()
    {
    OstTraceFunctionEntry0( CMTPIMAGEDPCOPYOBJECT_SETDEFAULTPARENTOBJECTL_ENTRY );
    TDriveNumber drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
    LEAVEIFERROR(drive,
            OstTraceExt2( TRACE_ERROR, CMTPIMAGEDPCOPYOBJECT_SETDEFAULTPARENTOBJECTL, "No driver number for %d! error code %d",iStorageId, munged_err));
    TChar driveLetter;
    iFramework.Fs().DriveToChar(drive, driveLetter);
    TFileName driveBuf;
    driveBuf.Append(driveLetter);
    driveBuf = BaflUtils::RootFolderPath(driveBuf.Left(1));
    delete iDest;
    iDest = NULL;
    iDest = driveBuf.AllocL();
    iNewParentHandle = KMTPHandleNoParent;
    OstTraceFunctionExit0( CMTPIMAGEDPCOPYOBJECT_SETDEFAULTPARENTOBJECTL_EXIT );
    }
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:20,代码来源:cmtpimagedpcopyobject.cpp

示例4: LoadIcons

EXPORT_C void LoadIcons(CArrayPtrFlat<CGulIcon> * aIconList, const TIconID* aIconDefs, 
			TInt aNbIcons, TInt aScale)
{
	CALLSTACKITEM_N(_CL(""), _CL("LoadIcons"));

	TFileName real; TFileName prev;
	CEikonEnv* env=CEikonEnv::Static();
	RFs& fs=env->FsSession();
	CWsScreenDevice* screen=env->ScreenDevice();
	RWsSession& ws=env->WsSession();
	RArray<TInt> Offsets; RFile File; bool file_is_open=false;
	CleanupClosePushL(Offsets);
	RFileReadStream s;
	int j=0;

	bool romfile=false;
	for (int i = 0; i<aNbIcons;i++)
	{
		TPtrC file((TText16*)aIconDefs[i].iMbmFile);
#ifdef __S60V3__
		if (file.FindF(_L("avkon"))==KErrNotFound) {
#endif
			
		if (prev.Compare(file)) {
#ifndef __S60V3__
			real=file;
#else
			TParse p; p.Set(file, 0, 0);
			real=_L("c:\\resource\\");
			real.Append(p.NameAndExt());				
				
#endif

#ifdef __WINS__
			real.Replace(0, 1, _L("z"));
#else
			if (! BaflUtils::FileExists(fs, real)) {
				real.Replace(0, 1, _L("e"));
			}
#endif
			prev=file;
			if (file_is_open) {
				s.Close();
				file_is_open=false;
			}
			if (real.Left(1).CompareF(_L("z"))==0) {
				romfile=true;
			} else {
				romfile=false;
				GetIconInfo(real, fs, File, s, Offsets, j);
				file_is_open=true;
			}
			++j;
		}

		auto_ptr<CWsBitmap> bitmap(new (ELeave) CWsBitmap(ws));
		if (!romfile) {
			RFile f1=File;
			s.Attach(f1, Offsets[aIconDefs[i].iBitmap]);	
			bitmap->InternalizeL(s);
		} else {
			TInt err=bitmap->Load(real, aIconDefs[i].iBitmap);
			if (err!=KErrNone) 
				User::Leave(err);
		}
		bitmap->SetSizeInTwips(screen);
#ifdef __S60V2__
		if (aScale>1) {
			auto_ptr<CWsBitmap> scaled(new (ELeave) CWsBitmap(ws));
			ScaleFbsBitmapL(bitmap.get(), scaled.get(), aScale);
			bitmap=scaled;
		}
#endif
		
		auto_ptr<CWsBitmap> mask(NULL);
		if ( aIconDefs[i].iMask != KErrNotFound )
			{
				mask.reset(new (ELeave) CWsBitmap(ws));
				if (!romfile) {
					RFile f2=File;
					s.Attach(f2, Offsets[aIconDefs[i].iMask]);
					mask->InternalizeL(s);
				} else {
					User::LeaveIfError(mask->Load(real, aIconDefs[i].iMask));
				}
				mask->SetSizeInTwips(screen);
#ifdef __S60V2__
				if (aScale>1) {
					auto_ptr<CWsBitmap> scaled(new (ELeave) CWsBitmap(ws));
					ScaleFbsBitmapL(mask.get(), scaled.get(), aScale);
					mask=scaled;
				}
#endif
			}

		auto_ptr<CGulIcon> icon(CGulIcon::NewL(bitmap.get(), mask.get()));
		bitmap.release(); mask.release();
		aIconList->AppendL(icon.get()); icon.release();
#ifdef __S60V3__
		} else {
//.........这里部分代码省略.........
开发者ID:flaithbheartaigh,项目名称:jaikuengine-mobile-client,代码行数:101,代码来源:icons.cpp

示例5: GetAlbumArtFilename

TInt CMusicPlayerImgEngine::GetAlbumArtFilename(const CMetadata &aMetadata, const TSize &aSize, TFileName &aCoverFilename, CImageDecoder **aDecoder) 
{
	/* Function returns KErrNotFound if we find nothing, it returns 0 if we find a file, and it returns 1 if the elemnt is in cache
	 * In aCacheIndex returns the cache index, if found there, or -1. If found in cache, the cache is updated.
	 * If NOT found in cache, aCoverFilename contains the cover filename. If aMetadata.iCover is valid (non-NULL)
	 * then the aCoverFilename is non-existent, e.g. e:\\Music\\Something\\Else.mp3_360.jpg The purpose in this case
	 * would be to identify the image in the cache.
	 * 
	 * The algorithm for finding the album art:
	 * 1. Check if there is aMetadata.iCover. If it does, check the cache, update aCoverFilename, return.
	 * 2. Check for KAlbumCoverNameGeneric (cover.jpg) in song's folder.
	 * 3. Check for KAlbumCoverNameGeneric2 (folder.jpg) in song's folder.
	 * 4. If aMetadata artist and album are non-NULL, check the Source/__Covers/Artist-Album.jpg
	 * 5. If enabled in Preferences, create a "hint" Source/__Covers/Artist-Album.hint having 0 bytes
	 * 6. If here, return KErrNotFound
	 */
	
	aMetadata.iFileDirEntry->GetFullPath(aCoverFilename,ETrue);
	LOG(ELogGeneral,1,"GetAlbumArtFilename++ (%S), iCover=%x",&aCoverFilename,aMetadata.iCover);

	TInt r,err;
	TEntry entry;
	
	*aDecoder=NULL;
	if(aMetadata.iCover) {
		aMetadata.iFileDirEntry->GetFullPath(aCoverFilename);
		//check if we have this in cache
		if(IsInCache(aCoverFilename,aSize)) {
			LOG(ELogGeneral,-1,"GetAlbumArtFilename-- (we have embedded cover, in cache)");
			return 1; 
		}
		else {
			TRAP(err,*aDecoder=CImageDecoder::DataNewL(iEikEnv->FsSession(),*aMetadata.iCover));
			if(!err) {
				LOG(ELogGeneral,-1,"GetAlbumArtFilename-- (we have embedded cover)");
				return 0; 
			}
			else LOG0("Instantiating a CImageDecoder for the embedded cover failed. Checking other options.");
		}
	}
	
	//check for KAlbumCoverNameGeneric
	aMetadata.iFileDirEntry->iParent->GetFullPath(aCoverFilename,ETrue);
	TInt pathLength=aCoverFilename.Length();
	aCoverFilename.Append(KAlbumCoverNameGeneric);
	if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
		return r;
	
	//check for KAlbumCoverNameGeneric2
	aCoverFilename.SetLength(pathLength);
	aCoverFilename.Append(KAlbumCoverNameGeneric2);
	if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
		return r;
	
	//if we are here, we need to check if we have valid Artist and Album metadata
	if(aMetadata.iAlbum && aMetadata.iArtist)
	{
		//we can construct Source/__Covers/Artist-Album.jpg
		aMetadata.iFileDirEntry->GetSource()->GetFullPath(aCoverFilename,ETrue);
		aCoverFilename.Append(KCoversFolderName);
		pathLength=aCoverFilename.Length();
		if(pathLength+aMetadata.iArtist->Length()+aMetadata.iAlbum->Length()+6<=KMaxFileName) //6= the dash + length of .jpg or .jpeg or .hint
		{
			//check for __Covers/Artist-Album.jpg
			aCoverFilename.Append(*aMetadata.iArtist);
			aCoverFilename.Append('-');
			aCoverFilename.Append(*aMetadata.iAlbum);
			aCoverFilename.Append(KAlbumCoverExtension);
			if((r=GetAlbumArtFilenameHelper(aSize,aCoverFilename,aDecoder))>=0)
				return r;
			
			//if we are here, the file does not exist!
			if((iPreferences->iPFlags&CMLauncherPreferences::EPreferencesCreateCoverHintFiles) &&
					(pathLength+KIgnoreFolderName().Length()+aMetadata.iArtist->Length()+aMetadata.iAlbum->Length()+6<=KMaxFileName)) //filename size requirements
			{
				//check first if the hint file is in the "IGNORE" folder
				aCoverFilename.SetLength(pathLength);
				aCoverFilename.Append(KIgnoreFolderName);
				aCoverFilename.Append(*aMetadata.iArtist);
				aCoverFilename.Append('-');
				aCoverFilename.Append(*aMetadata.iAlbum);
				aCoverFilename.Append(KHintFileExtension);
				if(iEikEnv->FsSession().Entry(aCoverFilename,entry)){
					//the hint file was not found in the IGNORE folder
					//we should create a hint file
					aCoverFilename.SetLength(pathLength);
					aCoverFilename.Append(*aMetadata.iArtist);
					aCoverFilename.Append('-');
					aCoverFilename.Append(*aMetadata.iAlbum);
					aCoverFilename.Append(KHintFileExtension);
					LOG0("Creating hint file for %S",&aCoverFilename);
					//first, we try to make the folder
					if(!iEikEnv->FsSession().MkDir(aCoverFilename.Left(pathLength))){
						//set the entry as hidden
						TTime modifTime;
						modifTime.UniversalTime();
						iEikEnv->FsSession().SetEntry(aCoverFilename.Left(pathLength),modifTime,KEntryAttHidden,0);
					}
					//now we create the file, IF it does not exist
					if(iEikEnv->FsSession().Entry(aCoverFilename,entry)){
//.........这里部分代码省略.........
开发者ID:lohanf,项目名称:MLauncher,代码行数:101,代码来源:MusicPlayerImgEngine.cpp


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