package tools import ( "io/fs" "os" "path/filepath" "strconv" "time" "velvettear/gosync/log" "velvettear/gosync/settings" ) var sourceFiles []string // unexported function(s) func getSourceFiles() []string { timestamp := time.Now() stats, error := os.Stat(settings.Source) if error != nil { log.Error("encountered an error getting the stats for the source", error.Error()) } if stats.IsDir() { log.Info("scanning source...", settings.Source) filepath.WalkDir(settings.Source, fillSourceFiles) log.InfoTimed("found "+strconv.Itoa(len(sourceFiles))+" source files", timestamp.UnixMilli()) } else { sourceFiles = append(sourceFiles, settings.Source) } return sourceFiles } func fillSourceFiles(path string, dir fs.DirEntry, err error) error { if err != nil { return err } if dir.IsDir() { return nil } sourceFiles = append(sourceFiles, path) return nil }