harvester/monitorplugins/mmcplugin/src/mmcfilelist.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 2 b73a2e62868f
equal deleted inserted replaced
0:c53acadfccc6 1:acef663c1218
    50 
    50 
    51 void CMmcFileList::ConstructL()
    51 void CMmcFileList::ConstructL()
    52 	{
    52 	{
    53 	iHem = CHarvesterEventManager::GetInstanceL();
    53 	iHem = CHarvesterEventManager::GetInstanceL();
    54 	iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
    54 	iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
       
    55 	CHarvesterCenRepUtil::GetIgnorePathL( iIgnorePaths );
    55 	}
    56 	}
    56 
    57 
    57 CMmcFileList::~CMmcFileList()
    58 CMmcFileList::~CMmcFileList()
    58 	{
    59 	{
    59 	if( iHem )
    60 	if( iHem )
    60 		{
    61 		{
    61 		iHem->ReleaseInstance();
    62 		iHem->ReleaseInstance();
    62 		}
    63 		}
    63 	RMediaIdUtil::ReleaseInstance();
    64 	RMediaIdUtil::ReleaseInstance();
       
    65 	iIgnorePaths.ResetAndDestroy();
       
    66 	iIgnorePaths.Close();
    64 	}
    67 	}
    65 
    68 
    66 TBool CMmcFileList::IsDescInArray(const TPtrC& aSearch, const RPointerArray<HBufC>& aArray)
    69 TBool CMmcFileList::IsDescInArray(const TPtrC& aSearch, const RPointerArray<HBufC>& aArray)
    67 	{
    70 	{
    68 	const TInt count = aArray.Count();
    71 	const TInt count = aArray.Count();
    94 	TUint32 mediaId( 0 );
    97 	TUint32 mediaId( 0 );
    95 	iMediaIdUtil->GetMediaId( aDrivePath, mediaId );
    98 	iMediaIdUtil->GetMediaId( aDrivePath, mediaId );
    96 	
    99 	
    97 	WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %d", mediaId );
   100 	WRITELOG1( "CMmcFileList::BuildFileListL - mediaId: %d", mediaId );
    98 	
   101 	
    99 	RPointerArray<HBufC> ignorePaths;
       
   100 	TCleanupItem cleanupItem( MdsUtils::CleanupPtrArray<HBufC>, &ignorePaths );
       
   101     CleanupStack::PushL( cleanupItem );
       
   102     
       
   103     CHarvesterCenRepUtil::GetIgnorePathL( ignorePaths );
       
   104 	
       
   105     CDir* directory = NULL;
   102     CDir* directory = NULL;
   106     TFileName name; 
   103     TFileName name; 
       
   104     TBool rootDir( ETrue );
   107     
   105     
   108 	while ( path->Count() > 0 )
   106 	while ( path->Count() > 0 )
   109 		{
   107 		{
   110 		TInt error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetDirFlags, directory );
   108 		TInt error( KErrNone );
       
   109 		if( rootDir )
       
   110 		    {
       
   111 		    error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetRootDirFlags, directory );
       
   112 		    rootDir = EFalse;
       
   113 		    }
       
   114 		else
       
   115 		    {
       
   116 		    error = aFs.GetDir( (*path)[0], KEntryAttDir, KHarvesterGetDirFlags, directory );
       
   117 		    }
   111 		if ( error == KErrNone )
   118 		if ( error == KErrNone )
   112 			{
   119 			{
   113 			for ( TInt i=0; i < directory->Count(); ++i )
   120 			for ( TInt i=0; i < directory->Count(); ++i )
   114 				{
   121 				{
   115 				TEntry entry = (*directory)[i];
   122 				TEntry entry = (*directory)[i];
   125 				    name.Append( entry.iName );     
   132 				    name.Append( entry.iName );     
   126 				    }
   133 				    }
   127 			
   134 			
   128 				if ( entry.IsDir() )
   135 				if ( entry.IsDir() )
   129 					{
   136 					{
   130 					// If path is too long, skip it as the file cannot be supported
   137 					// If path is too long with backslash, skip it as the file cannot be supported
   131 	                if( name.Length() >= KMaxPath )
   138 	                if( name.Length() + 1 >= KMaxPath )
   132 	                    {
   139 	                    {
   133 	                    continue;
   140 	                    continue;
   134 	                    }
   141 	                    }
   135 	                else
   142 	                else
   136 	                    {
   143 	                    {
   138 	                    }
   145 	                    }
   139 					
   146 					
   140 					// remove drive letter and colon from path
   147 					// remove drive letter and colon from path
   141 					TPtrC pathOnly = name.Mid( 2 );
   148 					TPtrC pathOnly = name.Mid( 2 );
   142 					
   149 					
   143 					if ( IsDescInArray( pathOnly, ignorePaths ) )
   150 					if ( IsDescInArray( pathOnly, iIgnorePaths ) )
   144 						{
   151 						{
   145 						continue;
   152 						continue;
   146 						}
   153 						}
   147 
   154 
   148 					path->AppendL( name );
   155 					path->AppendL( name );
   169 		path->Delete( 0 );
   176 		path->Delete( 0 );
   170 		delete directory;
   177 		delete directory;
   171 		directory = NULL;
   178 		directory = NULL;
   172 		}
   179 		}
   173 	
   180 	
   174 	CleanupStack::PopAndDestroy( &ignorePaths );
       
   175 	
       
   176 	CleanupStack::PopAndDestroy( path );
   181 	CleanupStack::PopAndDestroy( path );
   177 	
   182 	
   178 	WRITELOG( "CMmcFileList::BuildFileListL - end" );
   183 	WRITELOG( "CMmcFileList::BuildFileListL - end" );
   179 	}
   184 	}
   180 
   185