PiwigoDirectoryUploader/internal/pkg/localFileStructure/nodeBuilder.go

32 lines
485 B
Go
Raw Normal View History

2019-02-23 00:58:32 +01:00
package localFileStructure
import (
"os"
"path/filepath"
)
func ScanLocalFileStructure(path string) map[string]FileNode {
fileMap := make(map[string]FileNode)
err := filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
if path == p {
return nil
}
//TODO: Only allow jpg and png files here
fileMap[p] = FileNode{
2019-02-23 22:02:12 +01:00
key: p,
name: info.Name(),
isDir: info.IsDir(),
2019-02-23 00:58:32 +01:00
}
2019-02-23 22:02:12 +01:00
return nil
2019-02-23 00:58:32 +01:00
})
if err != nil {
panic(err)
}
return fileMap
}