This commit is contained in:
Matt Burchett 2018-10-17 17:21:16 +00:00
parent e0ccfda2ed
commit 3ee2c13ba3

View File

@ -9,13 +9,12 @@ import (
"time"
)
func main() {
var location string
var days int
flag.StringVar(&location, "location", "", "location to scan")
flag.IntVar(&days, "days", 0, "days to poll")
flag.Parse()
func isOlder(t time.Time, days int) bool {
hours := time.Duration(days*24) * time.Hour
return time.Now().Sub(t) > hours*time.Hour
}
func getFiles(location string, days int) error {
var files []string
err := filepath.Walk(location, func(path string, info os.FileInfo, err error) error {
files = append(files, path)
@ -25,15 +24,21 @@ func main() {
log.Fatal(err)
}
now := time.Now()
cutoff := now.Add(-int(days * time.Hour)
fmt.Println(cutoff)
for _, file := range files {
if diff := now.Sub(files.ModTime()); diff > cutoff {
fmt.Println(diff)
}
fmt.Println(file)
}
return err
}
func main() {
var location string
var days int
flag.StringVar(&location, "location", "", "location to scan")
flag.IntVar(&days, "days", 0, "days to poll")
flag.Parse()
_ = getFiles(location, days)
}