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