Exemplo n.º 1
0
BOOL RvFindRegex::include(FileData &file, const std::wstring& regex, const std::wstring& pathRoot) const
{
    if (pathRoot.size())
    {
        if (!boost::algorithm::istarts_with(file.getFileName(), pathRoot))
            return false;
    }
    return fpattern_matchn(regex.c_str() , file.getFileName().c_str() + (std::find(file.getFileName().rbegin(), file.getFileName().rend(), L'\\').base() - file.getFileName().begin()));
}
Exemplo n.º 2
0
BOOL NRvFindRegex::include(FileData &file, const std::wstring& regex, const std::wstring& pathRoot) const
{
    if (!boost::algorithm::iequals(pathRoot,
        boost::make_iterator_range(file.getFileName().begin(),
        std::find(file.getFileName().rbegin(), file.getFileName().rend(), L'\\').base())
        ))
        return false;
    return fpattern_matchn(regex.c_str(), file.getFileName().c_str() + (file.getFileName().end() - (std::find(file.getFileName().rbegin(), file.getFileName().rend(), L'\\').base() + 1)) );
}
Exemplo n.º 3
0
FileIterator::Status 
FileIterImpUnix::findNext(
            FileAttributes &attrs )
{
    FileIterator::Status status = FileIterator::cFindError;

    while ( _fd != NULL )
    {
        errno = 0;
        struct dirent* ent = ::readdir(_fd);
        if ( ent != NULL )
        {
            // we want to ignore the "." and ".." directories
            if ( (::strcmp( PERIOD.c_str(), ent->d_name) == 0) ||
                 (::strcmp( DOTDOT.c_str(), ent->d_name) == 0) )
            {
                continue;
            }

            // now see if the file should be filtered out
            if ( fpattern_matchn(_filter.c_str(), ent->d_name) == 0 )
            {
                continue;
            }

            status = FileIterator::cFound;

            String fullPath(_basePath);
            fullPath += FileUtils::PATH_SEP;
            fullPath += ent->d_name;

            FileUtils::getAttributes( fullPath, attrs );
        }
        else if ( errno == 0 )
        {
            status = FileIterator::cNoMoreFiles;
        }

        break; // found a file or no more files to be iterated
    }

    return status;
}