add: custom kpi and export log&cdr file

This commit is contained in:
2024-08-29 11:46:45 +08:00
parent 57161c7cab
commit cd7e5693f5
31 changed files with 1459 additions and 87 deletions

27
lib/file/file.go Normal file
View File

@@ -0,0 +1,27 @@
package file
import (
"os"
"path/filepath"
)
func GetFileAndDirCount(dir string) (int, int, error) {
var fileCount, dirCount int
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if path == dir {
return nil // 跳过当前目录
}
if info.IsDir() {
dirCount++
} else {
fileCount++
}
return nil
})
return fileCount, dirCount, err
}