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


C++ TPtrC::LocateReverse方法代码示例

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


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

示例1: testTPtrLocateReverse

LOCAL_C void testTPtrLocateReverse()
//
// Test locating in reverse on an empty TPtr
//
	{

	TPtrC a;
	test(a.LocateReverse('0')==KErrNotFound);
	test(a.LocateReverseF('0')==KErrNotFound);
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:10,代码来源:t_des.cpp

示例2: GetNextFileNameLC

// --------------------------------------------------------------------------
// CImageCapture::GetNextFileNameLC
// Get the file name
// --------------------------------------------------------------------------
HBufC* CImageCapture::GetNextFileNameLC(const TDesC& aName) const
{
    const TInt KNumberLength = 4; // this is to indicate the file numbering,
                                  // e.g. 0001, 0002, etc.
    const TInt KMaxIndex = 10000;
    const TInt KTimeRecordSize = 512;
    
    TPtrC filePathPtr;
    _LIT(KExtensionpng, ".png");
    _LIT(KSlash,"\\");
    
    // Gets the file extension.
    TPtrC fileExtension;
    fileExtension.Set(KExtensionpng);
   
    filePathPtr.Set(iSettings.iLogPath);
    TInt result = filePathPtr.LocateReverse('\\');
    TPtrC string;
    if(result!=KErrNotFound)
    	string.Set(filePathPtr.Left(result+1));
    
    TBuf8<KTimeRecordSize> fileName;
    fileName.Copy(string);
    
    if(iXmlFileName.Length()>0)
    {
    	TInt pos=iXmlFileName.LocateReverse('.');
    	TPtrC8 ptr;
    	if(pos!=KErrNotFound)
    	{
    		ptr.Set(iXmlFileName.Left(pos));
    		fileName.Append(ptr);
    	}
    	
		fileName.Append(KSlash);
    }
    
    fileName.Append(aName);
    HBufC* newFileName = HBufC::NewLC(fileName.Length()+ KNumberLength + fileExtension.Length() + 1);
    TPtr newFileNamePtr(newFileName->Des());
    newFileNamePtr.Copy(fileName);

    
    // Checks whether aNamexxxx.png already exists on the phone or not.
    // This is to prevent over-riding of any existing images with the same name
    TBool IsFileExist = ETrue;
    TInt index = 1;
    HBufC* buffer = HBufC::NewL(newFileNamePtr.MaxLength());
    TPtr bufferPtr(buffer->Des());
    while ((index < KMaxIndex) && (IsFileExist))
    {
        bufferPtr.Copy(newFileNamePtr);
        bufferPtr.AppendNumFixedWidth(index, EDecimal, KNumberLength);
        bufferPtr.Append(fileExtension);
        if (BaflUtils::FileExists(CCoeEnv::Static()->FsSession(), *buffer))
        {
        	index++;
        }
        else
        {
        	IsFileExist = EFalse;
        }
    }
    delete buffer;

    // If the index exceeds KMaxIndex, then we don't need to format the file name.
    if (index >= KMaxIndex)
    {
    	newFileNamePtr.AppendNum(index);
    }
    else
    {
    	newFileNamePtr.AppendNumFixedWidth(index, EDecimal, KNumberLength);
    }
    newFileNamePtr.Append(fileExtension);

    // If the index greated then KMaxIndex, then rollback to 1
    
    if (index >= KMaxIndex)
    {
    	index = 1;
    }
    
    return newFileName;
}
开发者ID:fedor4ever,项目名称:testfw,代码行数:89,代码来源:ImageCapture.cpp

示例3: RestoreFileInPrivateDirectoryL

// ---------------------------------------------------------------------------
// Re-creates backed-up file in private directory.
// ---------------------------------------------------------------------------
//
TInt CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL(
    const TDesC& aFileName )
    {
    AKNS_TRACE_DEBUG("CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL" );
    _LIT( KAknsStaticPath, "\\private\\10207114\\import" );
    _LIT( KAknsSknExtension, ".SKN" );
    TBool parseError = EFalse;
    TInt fileErr = KErrNone;

    HBufC* fileNameBuffer = HBufC::NewL( KMaxFileName );
    TParsePtrC fileName( aFileName );
    TPtr bufferPtr = fileNameBuffer->Des();

    // First append drive and static path.
    if ( fileName.DrivePresent() )
        {
        bufferPtr.Append( fileName.Drive() );
        }
    else
        {
        AKNS_TRACE_DEBUG("CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL parse error1" );
        parseError = ETrue;
        }
    if ( !parseError )
        {
        bufferPtr.Append( KAknsStaticPath );
        }

    if ( fileName.PathPresent() && !parseError )
        {
        // Take path without the trailing backslash.
        TPtrC path = fileName.Path().Left( fileName.Path().Length() - 1 );

        // Locate last backslash.
        TChar backslash('\\');
        TInt bsLoc = path.LocateReverse( backslash );

        // Append skin PID to the directory.
        bufferPtr.Append( fileName.Path().Mid( bsLoc ) );

        if ( fileName.ExtPresent() )
            {
            // Last, append filename. Now string is complete.
            bufferPtr.Append( fileName.NameAndExt() );

            // switch the extension and check for file existance.
            bufferPtr.Replace(
                bufferPtr.Length() - KExtensionLength,
                KExtensionLength,
                KAknsSknExtension );
            if ( !AknsSrvUtils::IsFile( iFsSession, bufferPtr ) )
                {
                // There is no matching .skn-file, do not restore the graphics file.
                fileErr = KErrNotFound;
                }

            // switch back the graphics file extension.
            bufferPtr.Replace(
                bufferPtr.Length() - KExtensionLength,
                KExtensionLength,
                fileName.Ext() );
            }
        else
            {
            AKNS_TRACE_DEBUG("CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL parse error2" );
            parseError = ETrue;
            }
        }
    else
        {
        AKNS_TRACE_DEBUG("CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL parse error3" );
        parseError = ETrue;
        }

    if( !parseError && fileErr == KErrNone )
        {
        if ( AknsSrvUtils::IsFile( iFsSession, bufferPtr ) )
            {
            // Do not restore, if the file already exists.
            fileErr = KErrAlreadyExists;
            }
        else
            {
            // Create the file.
            fileErr = iFile.Replace(
                iFsSession,
                bufferPtr,
                ( EFileWrite | EFileShareExclusive | EFileStream ) );
            }
        }

    AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::RestoreFileInPrivateDirectoryL parse ret=%d", fileErr );
    if ( fileErr != KErrNone )
        {
        // If error creating or parsing the file, skip to next one.
        return fileErr;
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:101,代码来源:aknssrvactivebackupdataclient.cpp

示例4: ParseTextL

/**
 * Wraps the text and sets it into the labels.
 */
void CAknTextControl::ParseTextL(const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths,const TWrapMethod& aWrapMethod)
    { 
	if ( aWrapMethod == ENoAllocation && iWrappedArray )
		{
		// We preallocate text required in construction of alert win, so we just replace the texts in labels.
        TPtrC remainder = Text();
		TChar endlchar('\n');
		TInt linebreak = remainder.LocateReverse(endlchar);
        
		TBuf<17 + KAknBidiExtraSpacePerLine> temp; //KEikAlertMaxMsgLength not declared in this scope

        if ( linebreak == KErrNotFound )
            {
            AknBidiTextUtils::ConvertToVisualAndClip(remainder, temp, *aFont, KMaxTInt, KMaxTInt );
            Line(0)->SetTextL(temp); // won't leave as there is enough space in buffer
            iLines[0]->iModified = ETrue;
            Line(1)->SetTextL(KNullDesC);
            iLines[1]->iModified = ETrue;
            }
        else
            {
            AknBidiTextUtils::ConvertToVisualAndClip(
                remainder.Left(linebreak), temp, *aFont, KMaxTInt, KMaxTInt );
            Line(0)->SetTextL(temp);
            iLines[0]->iModified = ETrue;
            if ( remainder.Length()-1 == linebreak) // Line break is the last character
                {
                Line(1)->SetTextL(KNullDesC);
                }
            else
                {
                AknBidiTextUtils::ConvertToVisualAndClip( 
                    remainder.Right(remainder.Length()-linebreak-1), temp, *aFont, KMaxTInt, KMaxTInt );
                Line(1)->SetTextL(temp); // we don't want new line to label, thus -1
                }
            iLines[1]->iModified = ETrue;		
			}
		return;
		}
	if (iTextIsAlreadyInLabel || !iWrappedArray)
		return;

    TInt maxLines = aLineWidths->Count();

    // user handles all text processing
    if ( aWrapMethod == ENoProcessing )
        {
        iWrappedArray->Reset();

        TPtrC remainder = Text();

        while ( remainder.Length() && iWrappedArray->Count() < maxLines )
            {
            const TText* textArray = remainder.Ptr();
            TInt textLength = remainder.Length();

            TInt i = 0;

            for ( ; i < textLength ; i++ )
                {
                TText t = textArray[i];

                if ( t == KLineFeed ||
                     t == KLineSeparator ||
                     t == KParagraphSeparator ||
                     t == KCarriageReturn )
                    {
                    break;
                    }
                }

            iWrappedArray->AppendL( remainder.Left( i ) );

            // After a CR, skip also possible matching LF
            if ( i < textLength - 1 &&
                 textArray[i] == KCarriageReturn &&
                 textArray[i + 1] == KLineFeed )
                {
                i++;
                }

            i++;

            if ( i >= textLength )
                {
                break;
                }
            remainder.Set( remainder.Right( textLength - i ) );
            }
        }

    else
        {
        TPtr text = Text();

        HBufC* visualBuffer = HBufC::NewLC( 
            text.Length() + maxLines * KAknBidiExtraSpacePerLine );
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:101,代码来源:akntextcontrol.cpp

示例5: doTestStepL

TVerdict CForceRemove::doTestStepL()
	{

#ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	// Wait up to 30 seconds to ensure both SWIS and the sisregistry server
	// have shut down
	_LIT(KSisRegistryServerName, "!SisRegistryServer");
	_LIT(KInstallServerName, "!InstallServer");
	TInt delaytime = 30; 

	while (delaytime-- > 0)
		{
		TFullName serverName;
		TFindServer find(KInstallServerName);
		if (KErrNotFound == find.Next(serverName))
			{
			find.Find(KSisRegistryServerName);
			if (KErrNotFound == find.Next(serverName))
				{
				break;
				}
			}
		User::After(1000000); // wait a second until the next test
		}
#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	
	TPtrC name;
	RTestUtilSessionSwi testutil;
	User::LeaveIfError(testutil.Connect());
	CleanupClosePushL(testutil);
	
	// If file deletion fails we'll try moving the file to a temp directory
	// for another process to clean up later.
	
	TTime currentTime;
	currentTime.UniversalTime();
	
	_LIT(KTempPathFormat, "\\temp\\%Lu");
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TBuf<128> tempPathFormat(sysDrive.Name());
	tempPathFormat.Append(KTempPathFormat);
	
	TFileName targetPath;
	targetPath.Format(tempPathFormat, currentTime.Int64());
	
	_LIT(KNumFiles, "numfiles");

#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	RArray<TUint> removeUids;
	CleanupClosePushL(removeUids);
#endif

	TInt num(0);
	GetIntFromConfig(ConfigSection(), KNumFiles, num);

	// Get the file names and use testutil to remove them
	for (TInt i = 0; i < num; ++i)
		{
		_LIT(KFile, "file");
		TBuf<32> key(KFile);
		key.AppendNum(i);
		
		if (!GetStringFromConfig(ConfigSection(), key, name))
			continue;
			
		INFO_PRINTF2(_L("ForceRemove - trying to delete file %S"), &name);

		TInt err = testutil.Delete(name);
		if (err != KErrNone && err != KErrNotFound && err != KErrPathNotFound)
			{
			INFO_PRINTF3(_L("RTestUtilSessionSwi::Delete(%S) returned %d, attempting move instead."), &name, err);
			TFileName source(name);
			TParsePtr parse(source);
			TFileName dest(targetPath);
			dest.Append(parse.Path());
			if (parse.DrivePresent())
				{
				dest[0] = source[0];
				}
			testutil.MkDirAll(dest);
			dest.Append(parse.NameAndExt());

			err = testutil.Move(source, dest);
			
			if (err != KErrNone)
				{
				INFO_PRINTF4(_L("Attempt to move from %S to %S returned %d"),
							&source, &dest, err);
				}
			}
#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
		_LIT(KRegistryPath, "\\sys\\install\\sisregistry\\");
		if (name.FindF(KRegistryPath) == KErrNotFound)
			continue;

		// Extract the uid and add it to our list
		TInt slashPos = name.LocateReverse('\\');
		TPtrC ptrUid = name.Mid(slashPos + 1);
		if (ptrUid.Length() != 8)
			continue;
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:101,代码来源:forceremove.cpp


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