Ejemplo n.º 1
0
HRESULT CAvpHeurDir::AddHeurDir(LPCWSTR lpszDirectory, BOOL bNormailized)
{
    assert(lpszDirectory && *lpszDirectory);
    if (!lpszDirectory || !*lpszDirectory)
        return E_INVALIDARG;

    assert(lpszDirectory && *lpszDirectory);
    if (!lpszDirectory || !*lpszDirectory)
        return S_FALSE;


    WinMod::CWinPath pathDir = lpszDirectory;
    if (!bNormailized)
    {
        pathDir.ExpandNormalizedPathName();
    }
    pathDir.AddBackslash();
    pathDir.m_strPath.MakeLower();
    m_HeurDirMap.SetAt(pathDir, 0);
    return S_OK;
}
Ejemplo n.º 2
0
void CUnique::AddCancelDoubleDir( const CString& ScanDir, BOOL bRecursion )
{
    WinMod::CWinPath DirPath;
    DirPath.m_strPath = ScanDir;
    DirPath.AddBackslash();
  
    if ( FALSE == WinMod::CWinPathApi::IsDirectory(DirPath.m_strPath) )
    {
        _ASSERT(0);
        return;
    }

    BOOL bExit = FALSE;
    POSITION Pos = m_DirPathMap.GetStartPosition();
    if (  NULL == Pos )
    {
        m_DirPathMap.SetAt( DirPath.m_strPath, bRecursion );
        bExit = TRUE;
    }
    else
    {
        //消重判断
        while ( Pos )
        {
            CAtlMap<CString, BOOL>::CPair* pPair = m_DirPathMap.GetNext( Pos );
            if ( -1 != DirPath.m_strPath.Find(pPair->m_key) && pPair->m_value )
            {
                //1 是扫描过的某个目录的子目录,并且扫描过的某个目录是递归扫描。
                //2 是扫描过的某个目录,并且扫描过的目录是递归扫描。
                //不管所要扫描的目录是否递归。它都已经被扫描过来。
                bExit = TRUE;
                break;
            }
        }
    }
    if ( bExit )
    {
        return;
    }

    //消重判断
    if ( bRecursion )
    {
        //1 不是扫描过的目录的子目录,而是已经扫描过目录的父目录,并且当前目录递归扫描(要对消重表进行消重)
        CAtlArray<CString> DelKeyArray;
        POSITION Pos = m_DirPathMap.GetStartPosition();
        while ( Pos )
        {
            CAtlMap<CString, BOOL>::CPair* pPair = m_DirPathMap.GetNext( Pos );
            if ( -1 != pPair->m_key.Find(DirPath.m_strPath) )
            {
                DelKeyArray.Add( pPair->m_key );
            }
        }
        size_t Num = DelKeyArray.GetCount();
        size_t i = 0;
        for(; i<Num; ++i )
        {
            m_DirPathMap.RemoveKey( DelKeyArray[i] );
        }
    }

    //1 并不是扫描过的目录的子目录,而是无关的目录。(添加新项)
    //2 并不是扫描过的目录的子目录,而是以扫描过目录的父目录,并且当前目录递归扫描。(要对消重表进行消重,之后添加新项)
    //3 是扫描过的某个目录的子目录,但扫描过的某个目录,并不是递归扫描。(添加新项)
    //4 有可能DirPath这个目录.已经非递归扫过,这里重新赋下值。(重新赋值)
    m_DirPathMap.SetAt( DirPath.m_strPath, bRecursion );
}