Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Fast regular expressions

, 29 Oct 2000
Compiles a regular expression into a fast automaton.

class CFileFindRecursive{
public:
      CFileFindRecursive(
          CString strStartDirectory,
          CString strWildCards,
          vector<CString>& vecMatchingFileNames)
          :m_rvecMatchingFileNames(vecMatchingFileNames),m_strWildCards(strWildCards)
      {
          FindInThisDirectory(strStartDirectory);
      }
      
private:
    void FindInThisDirectory(CString strDir)
    {
        CFileFind findFile;
        if( findFile.FindFile(strDir+"\\"+m_strWildCards) ){
              while(findFile.FindNextFile()){
                  if( !findFile.IsDirectory() ){
                        m_rvecMatchingFileNames.push_back(findFile.GetFilePath());
                  }
              }
        }
        Recurse(strDir);
    }
    void Recurse(CString str)
    {   
        CFileFind finder;
        CString strWildcard(str);
        strWildcard += _T("\\*.*");   // start working for files
        BOOL bWorking = finder.FindFile(strWildcard);   
        while (bWorking){
            bWorking = finder.FindNextFile();
            if (finder.IsDots())         continue;
            if (finder.IsDirectory()){
                FindInThisDirectory(finder.GetFilePath());
            }
        }
    }

    CString             m_strWildCards;
    vector<CString>&    m_rvecMatchingFileNames;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Martin Holzherr

Switzerland Switzerland
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 30 Oct 2000
Article Copyright 2000 by Martin Holzherr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid