2020-04-11 15:25:53 +00:00
|
|
|
package engine
|
2020-04-12 21:59:20 +00:00
|
|
|
|
2020-04-12 23:52:45 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2020-04-17 17:41:33 +00:00
|
|
|
// ScanDir walks through a directory and returns
|
2020-04-12 21:59:20 +00:00
|
|
|
// file paths contained inside.
|
2020-04-17 17:41:33 +00:00
|
|
|
func ScanDir(dir string) (files []string, err error) {
|
|
|
|
err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
2020-04-12 23:52:45 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return nil
|
|
|
|
}
|
2020-04-17 17:41:33 +00:00
|
|
|
if info.IsDir() {
|
2020-04-12 23:52:45 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-04-17 17:41:33 +00:00
|
|
|
files = append(files, path)
|
2020-04-12 23:52:45 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2020-04-17 17:41:33 +00:00
|
|
|
return files, err
|
2020-04-12 21:59:20 +00:00
|
|
|
}
|