Changeset 5997


Ignore:
Timestamp:
Apr 28, 2018, 12:51:08 PM (13 months ago)
Author:
cameron
Message:

Optimization for the case when no include/exclude processing of files is required

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/util/file_select.cpp

    r5965 r5997  
    196196    // The vector to accumulate the full list of collected files to be searched.
    197197    std::vector<fs::path> collectedPaths;
    198     FileSelectAccumulator fileAccum(collectedPaths);
    199 
     198   
    200199    // In this pass through command line arguments and the file hierarchy,
    201200    // we are just gathering file and subdirectory entries, so we silently
     
    203202    // error codes rather than raise exceptions.
    204203    boost::system::error_code errc;
     204   
     205    // In non-recursive greps with no include/exclude processing, we simply assemble the
     206    // paths.
     207    if ((DirectoriesFlag != Recurse) && (ExcludeFlag == "") && (IncludeFlag == "") && (ExcludeFromFlag == "")) {
     208        for (const std::string & f : inputFiles) {
     209            if (f == "-") {  // stdin, will always be searched.
     210                argv::UseStdIn = true;
     211                continue;
     212            }
     213            fs::path p(f);
     214            if (errc) {
     215                // If there was an error, we leave the file in the fileCandidates
     216                // list for later error processing.
     217                collectedPaths.push_back(p);
     218            } else if (fs::is_directory(p)) {
     219                if (DirectoriesFlag == Read) {
     220                    collectedPaths.push_back(p);
     221                }
     222            } else if (fs::is_regular_file(p)) {
     223                collectedPaths.push_back(p);
     224            } else {
     225                // Devices and unknown file types
     226                if (DevicesFlag == Read) {
     227                    collectedPaths.push_back(p);
     228                }
     229            }
     230        }
     231        return collectedPaths;
     232    }
     233   
     234    // Otherwise we need to filter paths according to some include/exclude rules.
     235   
     236    FileSelectAccumulator fileAccum(collectedPaths);
    205237   
    206238    // At each level we gather candidate file and directory names and then
Note: See TracChangeset for help on using the changeset viewer.