Exemplo n.º 1
0
xpr_bool_t ProgramAss::getItemFromExt(const xpr_tchar_t *aExt, xpr_uint_t aType, ProgramAssDeque &aProgramAssDeque)
{
    FileFilterMgr &sFileFilterMgr = FileFilterMgr::instance();

    const xpr_tchar_t *sExts;
    FilterItem *sFilterItem;
    ProgramAssItem *sProgramAssItem;
    ProgramAssDeque::iterator sIterator;

    sIterator = mProgramAssDeque.begin();
    for (; sIterator != mProgramAssDeque.end(); ++sIterator)
    {
        sProgramAssItem = *sIterator;
        if (XPR_IS_NULL(sProgramAssItem))
            continue;

        if (!XPR_ANY_BITS(sProgramAssItem->mType, aType))
            continue;

        sExts = sProgramAssItem->mExts.c_str();
        if (sProgramAssItem->mMethod == ProgramAssMethodFilter)
        {
            sFilterItem = sFileFilterMgr.getFilterFromName(sProgramAssItem->mFilterName);
            if (XPR_IS_NOT_NULL(sFilterItem))
                sExts = sFilterItem->mExts.c_str();
        }

        if ((_tcsicmp(sExts, XPR_STRING_LITERAL("*.*")) == 0) ||
            (XPR_IS_NOT_NULL(aExt) && IsEqualFilter(sExts, aExt) == XPR_TRUE))
        {
            aProgramAssDeque.push_back(sProgramAssItem);
        }
    }

    return (aProgramAssDeque.empty() == false) ? XPR_TRUE : XPR_FALSE;
}
Exemplo n.º 2
0
xpr_sint_t Filter::getIndex(const xpr_tchar_t *aPath, xpr_bool_t aFolder)
{
    FilterItem *sFilterItem;
    FilterDeque::iterator sIterator;

    if (XPR_IS_TRUE(aFolder))
    {
        sIterator = mFilterDeque.begin();
        for (; sIterator != mFilterDeque.end(); ++sIterator)
        {
            sFilterItem = *sIterator;
            if (XPR_IS_NULL(sFilterItem))
                continue;

            if (_tcsicmp(sFilterItem->mExts.c_str(), XPR_STRING_LITERAL("*")) == 0)
                return (xpr_sint_t)std::distance(mFilterDeque.begin(), sIterator);
        }

        return -1;
    }

    if (XPR_IS_NULL(aPath))
        return 0;

    const xpr_tchar_t *sExt = GetFileExt(aPath);
    if (XPR_IS_NOT_NULL(sExt))
        sExt++;

    if (XPR_IS_NOT_NULL(sExt))
    {
        sIterator = mFilterDeque.begin();
        for (; sIterator != mFilterDeque.end(); ++sIterator)
        {
            sFilterItem = *sIterator;
            if (XPR_IS_NULL(sFilterItem))
                continue;

            if (_tcsicmp(sFilterItem->mExts.c_str(), XPR_STRING_LITERAL("*")) == 0 ||
                _tcsicmp(sFilterItem->mExts.c_str(), XPR_STRING_LITERAL("*.*")) == 0)
                continue;

            if (IsEqualFilter(sFilterItem->mExts.c_str(), sExt))
                return (xpr_sint_t)std::distance(mFilterDeque.begin(), sIterator);
        }
    }

    sIterator = mFilterDeque.begin();
    for (; sIterator != mFilterDeque.end(); ++sIterator)
    {
        sFilterItem = *sIterator;
        if (XPR_IS_NULL(sFilterItem))
            continue;

        if (_tcsicmp(sFilterItem->mExts.c_str(), XPR_STRING_LITERAL("*")) == 0 ||
            _tcsicmp(sFilterItem->mExts.c_str(), XPR_STRING_LITERAL("*.*")) != 0)
            continue;

        if (IsEqualFilter(sFilterItem->mExts.c_str(), sExt))
            return (xpr_sint_t)std::distance(mFilterDeque.begin(), sIterator);
    }

    return -1;
}
Exemplo n.º 3
0
xpr_size_t ProgramAss::indexFromExt(const xpr_tchar_t *aExt, xpr_uint_t aType)
{
    FileFilterMgr &sFileFilterMgr = FileFilterMgr::instance();

    const xpr_tchar_t *sExts;
    FilterItem *sFilterItem;
    ProgramAssItem *sProgramAssItem;
    ProgramAssDeque::iterator sIterator;

    if (XPR_IS_NOT_NULL(aExt))
    {
        sIterator = mProgramAssDeque.begin();
        for (; sIterator != mProgramAssDeque.end(); ++sIterator)
        {
            sProgramAssItem = *sIterator;
            if (XPR_IS_NULL(sProgramAssItem))
                continue;

            if (!XPR_ANY_BITS(sProgramAssItem->mType, aType))
                continue;

            sExts = sProgramAssItem->mExts.c_str();
            if (sProgramAssItem->mMethod == ProgramAssMethodFilter)
            {
                sFilterItem = sFileFilterMgr.getFilterFromName(sProgramAssItem->mFilterName);
                if (XPR_IS_NOT_NULL(sFilterItem))
                    sExts = sFilterItem->mExts.c_str();
            }

            if (_tcsicmp(sExts, XPR_STRING_LITERAL("*.*")) == 0)
                continue;

            if (IsEqualFilter(sExts, aExt) == XPR_TRUE)
                return std::distance(mProgramAssDeque.begin(), sIterator);
        }
    }

    sIterator = mProgramAssDeque.begin();
    for (; sIterator != mProgramAssDeque.end(); ++sIterator)
    {
        sProgramAssItem = *sIterator;
        if (XPR_IS_NULL(sProgramAssItem))
            continue;

        if (!XPR_ANY_BITS(sProgramAssItem->mType, aType))
            continue;

        sExts = sProgramAssItem->mExts.c_str();
        if (sProgramAssItem->mMethod == ProgramAssMethodFilter)
        {
            sFilterItem = sFileFilterMgr.getFilterFromName(sProgramAssItem->mFilterName);
            if (XPR_IS_NOT_NULL(sFilterItem))
                sExts = sFilterItem->mExts.c_str();
        }

        if (_tcsicmp(sExts, XPR_STRING_LITERAL("*.*")) != 0)
            continue;

        if (IsEqualFilter(sExts, aExt) == XPR_TRUE)
            return std::distance(mProgramAssDeque.begin(), sIterator);
    }

    return -1;
}