// ReadFiles reads all the specified files and parses them
ReadFiles reads all the specified files and parses them
// ReadFiles reads all the specified files and parses them
func (w Watch) ReadFiles() {
	for _, fileStr := range w.Files {
		file, err := os.Open(fileStr)
		if err != nil {
			log.Error("Error opening file ", fileStr, ": ", err)
			continue
		}
		reader := bufio.NewReader(file)
		flagFound := 0
		flaggedLines := []string{}
		var line string
	readLoop:
		for {
			line, err = reader.ReadString('\n')
			if err != nil {
				break readLoop
			}
			inRange := w.isLineInRange(line)
			if inRange {
				if w.testLine(line) {
					flagFound++
					flaggedLines = append(flaggedLines, line)
				}
			}
		}
		totalName, err := writeFile(flaggedLines, w.OutputDir, file.Name())
		if err != nil {
			log.Error("Error Writing to output file: ", err)
			continue
		}
		if flagFound > 0 {
			log.Infof("Found %d flagged Phrases in %v. Wrote phrases to %v", flagFound, file.Name(), totalName)
		}
		file.Close() 
	}
}
func ( w Watch ) ReadFiles ( ) { for _ , fileStr := range w . Files { file , err := os . Open ( fileStr ) if err != nil { log . Error ( " " , fileStr , " " , err ) continue } reader := bufio . NewReader ( file ) flagFound := 0 flaggedLines := [ ] string { } var line string readLoop : for { line , err = reader . ReadString ( '\n' ) if err != nil { break readLoop } inRange := w . isLineInRange ( line ) if inRange { if w . testLine ( line ) { flagFound ++ flaggedLines = append ( flaggedLines , line ) } } } totalName , err := writeFile ( flaggedLines , w . OutputDir , file . Name ( ) ) if err != nil { log . Error ( " " , err ) continue } if flagFound > 0 { log . Infof ( " " , flagFound , file . Name ( ) , totalName ) } file . Close ( ) } }
ReadFiles reads all the specified files and parses them
ReadFiles reads all the specified files and parses them
//Do this because defers in for loops is bad