filemanager/Engine/src/Cfilemanagerindexiterator.cpp
branchRCL_3
changeset 39 65326cf895ed
parent 0 6a9f87576119
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Goes through the list of given files
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "Cfilemanagerindexiterator.h"
       
    21 #include "CFileManagerEngine.h"
       
    22 #include "CFileManagerCommonDefinitions.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CFileManagerIndexIterator::NewL
       
    28 // 
       
    29 // -----------------------------------------------------------------------------
       
    30 // 
       
    31 CFileManagerIndexIterator* CFileManagerIndexIterator::NewL
       
    32     ( CFileManagerEngine& aEngine, 
       
    33       CArrayFixFlat<TInt>& aIndexList, 
       
    34       const TDesC& aDstDir )
       
    35     {
       
    36     CFileManagerIndexIterator* self = new( ELeave )
       
    37         CFileManagerIndexIterator( aEngine, aIndexList, aDstDir );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CFileManagerIndexIterator::CFileManagerIndexIterator
       
    46 // 
       
    47 // -----------------------------------------------------------------------------
       
    48 // 
       
    49 CFileManagerIndexIterator::CFileManagerIndexIterator
       
    50     ( CFileManagerEngine& aEngine, 
       
    51       CArrayFixFlat< TInt >& aIndexList, 
       
    52       const TDesC& aDstDir ):
       
    53     iEngine( aEngine ),
       
    54     iIndexList( aIndexList ),
       
    55     iDstDir( aDstDir )
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CFileManagerIndexIterator::~CFileManagerIndexIterator
       
    61 // Destructor
       
    62 // -----------------------------------------------------------------------------
       
    63 // 
       
    64 CFileManagerIndexIterator::~CFileManagerIndexIterator()
       
    65     {
       
    66     delete iSrc;
       
    67     delete iDst;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CFileManagerIndexIterator::ConstructL
       
    72 // 
       
    73 // -----------------------------------------------------------------------------
       
    74 // 
       
    75 void CFileManagerIndexIterator::ConstructL()
       
    76     {
       
    77     // We need double destination size
       
    78     // because source and target folder can be
       
    79     // KMaxFileName sized and those are append
       
    80     // to same buffer.
       
    81     iDst = HBufC::NewL( KFmgrDoubleMaxFileName );
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CFileManagerIndexIterator::CurrentL
       
    86 // 
       
    87 // -----------------------------------------------------------------------------
       
    88 // 
       
    89 void CFileManagerIndexIterator::CurrentL(
       
    90         HBufC** aSrc,
       
    91         HBufC** aDst,
       
    92         TFileManagerTypeOfItem& aItemType )
       
    93     {
       
    94     delete iSrc;
       
    95     iSrc = NULL;
       
    96     iSrc = iEngine.IndexToFullPathL( iIndexList.At( iCurrentIndex ) );
       
    97 
       
    98     TPtr ptrDst( iDst->Des() );
       
    99     ptrDst.Copy( iDstDir );
       
   100     TParsePtrC parse( *iSrc );
       
   101     ptrDst.Append( parse.NameAndExt() );
       
   102 
       
   103     *aSrc = iSrc;
       
   104     *aDst = iDst;
       
   105 
       
   106     aItemType = EFileManagerFile;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CFileManagerIndexIterator::NextL
       
   111 // 
       
   112 // -----------------------------------------------------------------------------
       
   113 // 
       
   114 TBool CFileManagerIndexIterator::NextL()
       
   115     {
       
   116     ++iCurrentIndex;
       
   117     if( iCurrentIndex < iIndexList.Count())
       
   118         {
       
   119         return ETrue;
       
   120         }
       
   121 
       
   122     return EFalse;
       
   123     }
       
   124 
       
   125 // End of File