goldsmith/loader.go

37 lines
618 B
Go
Raw Normal View History

2016-01-10 11:17:35 +00:00
package goldsmith
import "path/filepath"
2018-12-09 20:45:06 +00:00
type loader struct {
Initializer
}
2016-01-10 11:17:35 +00:00
2016-08-21 19:54:44 +00:00
func (*loader) Name() string {
return "loader"
}
2018-12-09 20:45:06 +00:00
func (*loader) Initialize(ctx *Context) (Filter, error) {
2016-06-11 20:13:16 +00:00
infos := make(chan fileInfo)
2018-12-08 19:18:51 +00:00
go scanDir(ctx.goldsmith.sourceDir, infos)
2016-01-10 11:17:35 +00:00
2016-06-11 20:13:16 +00:00
for info := range infos {
if info.IsDir() {
continue
}
2018-12-08 19:18:51 +00:00
relPath, _ := filepath.Rel(ctx.goldsmith.sourceDir, info.path)
2016-06-11 23:24:06 +00:00
2018-12-08 19:18:51 +00:00
file := &File{
sourcePath: relPath,
Meta: make(map[string]interface{}),
modTime: info.ModTime(),
size: info.Size(),
dataPath: info.path,
2016-06-11 23:24:06 +00:00
}
2018-12-08 19:18:51 +00:00
ctx.DispatchFile(file)
2016-01-10 11:17:35 +00:00
}
2016-07-10 20:05:23 +00:00
return nil, nil
2016-01-10 11:17:35 +00:00
}