-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.go
48 lines (39 loc) · 781 Bytes
/
run.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
package main
import (
"io"
"io/fs"
"log"
"path/filepath"
)
func run(w io.Writer, c *config) error {
var delLogger *log.Logger
return filepath.Walk(c.root, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
}
if filterOut(path, c.ext, c.size, c.modDate, info) {
return nil
}
if c.list {
return listFile(w, path)
}
if len(c.logFile) != 0 {
file, err := writeToLog(c)
if err != nil {
return err
}
c.out = file
defer file.Close()
}
if len(c.archive) != 0 {
if err := archiveFile(c.archive, c.root, path); err != nil {
return err
}
}
if c.del {
delLogger = log.New(c.out, "DELETED FILE: ", log.LstdFlags)
return delFile(path, delLogger)
}
return listFile(w, path)
})
}