[agent-operator] - add tag from gzip folder

This commit is contained in:
zeaslity
2024-04-26 10:20:12 +08:00
parent 08e5a4d422
commit 7f4a4d877e
7 changed files with 101 additions and 43 deletions

View File

@@ -150,11 +150,20 @@ func FileExistAndNotNull(filename string) bool {
return size > 0
}
// ListAllFileInFolder 列出一个目录中的所有文件返回文件名忽略folder不带全路径
func ListAllFileInFolder(folderName string) ([]string, error) {
return listAllFileInFolderWithFullPath(folderName, false)
}
func listAllFileInFolderWithFullPath(folderName string, fullPath bool) ([]string, error) {
files := make([]string, 0)
err := filepath.Walk(folderName, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
files = append(files, info.Name())
if fullPath {
files = append(files, path)
} else {
files = append(files, info.Name())
}
}
return nil
})