-
Notifications
You must be signed in to change notification settings - Fork 0
/
files.go
53 lines (43 loc) · 942 Bytes
/
files.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package aph
import (
"log"
"os"
"path/filepath"
"strings"
"time"
)
func checkFileNotStale(path string) {
info, err := os.Stat(path)
if err != nil {
return
}
if info.ModTime().Before(time.Now().AddDate(0, -11, 0)) {
log.Printf("WARNING: %s is over a month old", path)
} else {
// log.Printf("%s is fresh", path)
}
}
func ensureFile(path, remedy string) {
if !fileExists(path) {
log.Fatalf("ERROR: %s does not exist: %s", path, remedy)
}
}
func findAllDirs(path string, skipDirs []string) []string {
dirs := []string{}
skipSet := newStringSet(skipDirs...)
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if path == "." || !info.IsDir() {
return nil
}
if strings.HasPrefix(path, ".") || skipSet[path] {
return filepath.SkipDir
}
dirs = append(dirs, path)
return nil
})
return dirs
}
func fileExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}