Andy Hsu 7db3975b18
wip: refactor offline download (#5331)
* base tool

* working: aria2
2023-10-04 16:27:08 +08:00

28 lines
444 B
Go

package offline_download
import (
"os"
"path/filepath"
)
func GetFiles(dir string) ([]*File, error) {
var files []*File
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
files = append(files, &File{
Name: info.Name(),
Size: info.Size(),
Path: path,
})
}
return nil
})
if err != nil {
return nil, err
}
return files, nil
}