2019-02-23 00:58:32 +01:00
|
|
|
package localFileStructure
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2019-02-24 21:38:28 +01:00
|
|
|
func ScanLocalFileStructure(path string) (map[string]FilesystemNode,error){
|
2019-02-24 00:33:18 +01:00
|
|
|
fileMap := make(map[string]FilesystemNode)
|
2019-02-23 00:58:32 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-02-24 00:33:18 +01:00
|
|
|
fileMap[p] = FilesystemNode{
|
|
|
|
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 {
|
2019-02-24 21:38:28 +01:00
|
|
|
return nil, err
|
2019-02-23 00:58:32 +01:00
|
|
|
}
|
|
|
|
|
2019-02-24 21:38:28 +01:00
|
|
|
return fileMap, nil
|
2019-02-23 00:58:32 +01:00
|
|
|
}
|