|
@@ -1,21 +1,20 @@
|
|
|
package util
|
|
|
|
|
|
import (
|
|
|
- "cicv-data-closedloop/pji/common/log"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
-func ListAbsolutePathWithSuffixAndSort(dir string, suffix string) []string {
|
|
|
+func ListAbsolutePathWithSuffixAndSort(dir string, suffix string) ([]string, error) {
|
|
|
var result []string
|
|
|
if !strings.HasSuffix(dir, "/") {
|
|
|
dir = dir + "/"
|
|
|
}
|
|
|
files, err := os.ReadDir(dir)
|
|
|
if err != nil {
|
|
|
- log.GlobalLogger.Error("读取目录", dir, "报错:", err)
|
|
|
+ return nil, err
|
|
|
}
|
|
|
for _, file := range files {
|
|
|
if strings.HasSuffix(file.Name(), suffix) {
|
|
@@ -26,7 +25,7 @@ func ListAbsolutePathWithSuffixAndSort(dir string, suffix string) []string {
|
|
|
sort.Slice(result, func(i, j int) bool {
|
|
|
return filepath.Base(result[i]) < filepath.Base(result[j])
|
|
|
})
|
|
|
- return result
|
|
|
+ return result, nil
|
|
|
}
|
|
|
|
|
|
// RemoveDir 递归删除目录及其下的所有文件和子目录
|