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


C++ TPath::Length方法代码示例

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


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

示例1: UpdateDataArraysL

// ---------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::UpdateDataArraysL
// ---------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::UpdateDataArraysL()
    {
    TDriveList driveList;
    TInt driveCount;
    User::LeaveIfError( DriveInfo::GetUserVisibleDrives(
        iCoeEnv->FsSession(), driveList, driveCount, KDriveAttAll ) );
    TPath rootPath;
    TDriveNumber driveNumber;
    AknCommonDialogsDynMem::TMemoryTypes memoryType;
    
    CDesCArrayFlat* driveArray = STATIC_CAST( CDesCArrayFlat*, iDriveArray );
    CDesCArrayFlat* defaultFolderArray =
        STATIC_CAST( CDesCArrayFlat*, iDefaultFolderArray );
    driveArray->Reset();
    defaultFolderArray->Reset();
    
    if ( iDefDriveArray != NULL && iDefDefaultFolderArray != NULL )
        {
        for ( TInt i = 0; i < KMaxDrives; i++ )
            {
            TInt driveExist = driveList[i];
            if ( driveExist )
                {
                driveNumber = TDriveNumber( i );
                rootPath.Zero();
                memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
                if( memoryType & iIncludedMedias )
                    {
                    User::LeaveIfError(
                    PathInfo::GetRootPath( rootPath, driveNumber ) );
                    }
                else
                    {
                    continue;
                    }
                
                TBool isUserDefined = EFalse;
                // add right location even user's location with wrong sequence
                for ( TInt j = 0; j < iDefDriveArray->MdcaCount(); j++ )
                    {
                    // same drive info and user's root path must under c:\data\.
                    // try to get the location
                    if ( ( *iDefDriveArray )[j].FindC( rootPath ) == 0 )
                        {
                        // Use user's root path, part of user definiens
                        // (lowercase) may be replaced by system rootPath
                        rootPath.Append( ( *iDefDriveArray )[j].Right( 
                            ( *iDefDriveArray )[j].Length() - rootPath.Length() ) );
                        driveArray->AppendL( rootPath );
                        defaultFolderArray->AppendL( ( *iDefDefaultFolderArray )[j] );
                        isUserDefined = ETrue;
                        break;
                        }
                    }
                if ( !isUserDefined )
                    {
                    // user does not define location for this drive
                    // use the default
                    driveArray->AppendL( rootPath );
                    defaultFolderArray->AppendL( KNullDesC );
                    }
                }
            }
        }
    else
        {
        for ( TInt i=0; i<KMaxDrives; i++ )
            {
            TInt drive = driveList[i];
            driveNumber = TDriveNumber( i );
            if (drive)
                {
                memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
                if( memoryType & iIncludedMedias )
                    {
                    User::LeaveIfError(
                        PathInfo::GetRootPath( rootPath, driveNumber ) );
                    driveArray->AppendL( rootPath );
                    defaultFolderArray->AppendL( KNullDesC );
                    }
                }
            }
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:88,代码来源:caknmemoryselectionmodelmultidrive.cpp

示例2: testRescaleUtility

void T_CntImageRescaler::testRescaleUtility()
{
    // delete the possible image directory, it must not leave
    // even if the folder was not found. 
    TRAPD( err, TCntImageRescaleUtility::DeleteImageDirectoryL() );
    test( err == KErrNone );
    
    // path for image directory, existense of the directory is not
    // checked
    TPath path = TCntImageRescaleUtility::ImageDirectoryL();
    test( path.Length() > 0 );
    test( path.Find(KImagesFolder) != KErrNotFound );
    
    TPath dir = TCntImageRescaleUtility::CreateImageDirectoryL();
    test( dir.Length() > 0 );
    test( dir.Find( KImagesFolder) != KErrNotFound );
  
    // make a test image file (empty file) 
    RFs fs;
    CleanupClosePushL( fs );
    User::LeaveIfError( fs.Connect() );
    
    TPath imagePath;
    imagePath.Append( dir );
    imagePath.Append( KImageName );
    
    RFile file;
    CleanupClosePushL(file);
    User::LeaveIfError(file.Create( fs, imagePath, EFileWrite ));
    CleanupStack::PopAndDestroy();
    
    CContactItem* item  = CContactItem::NewLC(KUidContactCard);
    CContactItemField* field = CContactItemField::NewL( KStorageTypeText, KUidContactFieldCodImage );
    field->SetMapping( KUidContactFieldVCardMapUnknown );
    item->AddFieldL( *field );

    // add image without GUID
    TRAPD( err2, TCntImageRescaleUtility::StoreImageFieldL( *item, imagePath ) );
    test( err2 == KErrNone );
    
    // then update with GUID value
    _LIT(KGuid, "guid");
    TBufC<4> buffer ( KGuid );
    item->SetUidStringL( buffer );
    
    TRAPD( err3, TCntImageRescaleUtility::UpdateImageNameL( *item ) );
    test( err3 == KErrNone );
    
    CContactItemFieldSet& fields = item->CardFields();
    TInt privateImageIndex = fields.Find( KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown );
    test( privateImageIndex != KErrNotFound );
    
    TPtrC fieldText = fields[privateImageIndex].TextStorage()->Text();
    
    // how it should look like
    TPath newPath;
    newPath.Append( TCntImageRescaleUtility::ImageDirectoryL() );
    newPath.Append( buffer );
    newPath.Append( KImageName );
    RDebug::Print( _L("%S"), &newPath );
    RDebug::Print( _L("%S"), &fieldText );
    
    test( newPath.Compare(fieldText) == 0 );
    BaflUtils::DeleteFile( fs, newPath );
    CleanupStack::PopAndDestroy(2); // item, RFs
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:66,代码来源:t_cntimagerescaler.cpp


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