goldsmith/loader.go
2018-12-09 12:45:06 -08:00

37 lines
618 B
Go

package goldsmith
import "path/filepath"
type loader struct {
Initializer
}
func (*loader) Name() string {
return "loader"
}
func (*loader) Initialize(ctx *Context) (Filter, error) {
infos := make(chan fileInfo)
go scanDir(ctx.goldsmith.sourceDir, infos)
for info := range infos {
if info.IsDir() {
continue
}
relPath, _ := filepath.Rel(ctx.goldsmith.sourceDir, info.path)
file := &File{
sourcePath: relPath,
Meta: make(map[string]interface{}),
modTime: info.ModTime(),
size: info.Size(),
dataPath: info.path,
}
ctx.DispatchFile(file)
}
return nil, nil
}