package readFuzz

import (
	"io"
	"io/ioutil"
	"os"

	"git.thisco.de/vbatts/fuzz-walker/walker"
)

func init() {
	walker.RegisterFuzzFunc(Name, FuzzFunc)
}

const Name = "readFuzz"

func FuzzFunc(path string, info os.FileInfo) error {
	if !info.Mode().IsRegular() {
		return nil
	}

	fd, err := os.Open(path)
	if err != nil {
		return err
	}
	defer fd.Close()

	_, err = io.Copy(ioutil.Discard, fd)
	return err
}
