refactor /cmd/prune/main.go#ls to /pkg/fs/ls.go
This commit is contained in:
@@ -16,6 +16,8 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"ffmpeg.d/pkg/fs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -244,23 +246,9 @@ func mv(wPath, rPath string) error {
|
||||
}
|
||||
|
||||
func lsd(d string) ([]string, error) {
|
||||
return ls(d, true)
|
||||
return fs.LsD(d)
|
||||
}
|
||||
|
||||
func lsf(d string) ([]string, error) {
|
||||
return ls(d, false)
|
||||
}
|
||||
|
||||
func ls(d string, dirs bool) ([]string, error) {
|
||||
entries, err := os.ReadDir(d)
|
||||
|
||||
results := make([]string, 0, len(entries))
|
||||
for i := range entries {
|
||||
if dirs == entries[i].IsDir() {
|
||||
results = append(results, path.Join(d, entries[i].Name()))
|
||||
}
|
||||
}
|
||||
sort.Strings(results)
|
||||
|
||||
return results, err
|
||||
return fs.LsF(d)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user