summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/filecheck/collect.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/plugin/go.d/modules/filecheck/collect.go')
-rw-r--r--src/go/plugin/go.d/modules/filecheck/collect.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/filecheck/collect.go b/src/go/plugin/go.d/modules/filecheck/collect.go
new file mode 100644
index 000000000..077ad86c6
--- /dev/null
+++ b/src/go/plugin/go.d/modules/filecheck/collect.go
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package filecheck
+
+import (
+ "errors"
+ "io/fs"
+ "os"
+)
+
+func (f *Filecheck) collect() (map[string]int64, error) {
+ mx := make(map[string]int64)
+
+ f.collectFiles(mx)
+ f.collectDirs(mx)
+
+ return mx, nil
+}
+
+type statInfo struct {
+ path string
+ exists bool
+ fi fs.FileInfo
+}
+
+func getStatInfo(path string) *statInfo {
+ fi, err := os.Stat(path)
+ if err != nil {
+ return &statInfo{
+ path: path,
+ exists: !errors.Is(err, fs.ErrNotExist),
+ }
+ }
+
+ return &statInfo{
+ path: path,
+ exists: true,
+ fi: fi,
+ }
+}