master
go 40 lines 568 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package filecheck
4
5 import (
6 "errors"
7 "io/fs"
8 "os"
9 )
10
11 func (c *Collector) collect() (map[string]int64, error) {
12 mx := make(map[string]int64)
13
14 c.collectFiles(mx)
15 c.collectDirs(mx)
16
17 return mx, nil
18 }
19
20 type statInfo struct {
21 path string
22 exists bool
23 fi fs.FileInfo
24 }
25
26 func getStatInfo(path string) *statInfo {
27 fi, err := os.Stat(path)
28 if err != nil {
29 return &statInfo{
30 path: path,
31 exists: !errors.Is(err, fs.ErrNotExist),
32 }
33 }
34
35 return &statInfo{
36 path: path,
37 exists: true,
38 fi: fi,
39 }
40 }