goldsmith/loader.go

35 lines
604 B
Go
Raw Normal View History

2016-01-10 11:17:35 +00:00
package goldsmith
import "path/filepath"
2021-04-25 06:03:12 +00:00
type loader struct{}
2016-01-10 11:17:35 +00:00
2016-08-21 19:54:44 +00:00
func (*loader) Name() string {
return "loader"
}
2021-04-25 15:56:07 +00:00
func (*loader) Initialize(context *Context) error {
2016-06-11 20:13:16 +00:00
infos := make(chan fileInfo)
2021-04-25 15:56:07 +00:00
go scanDir(context.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
}
2021-04-25 15:56:07 +00:00
relPath, _ := filepath.Rel(context.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
}
2021-04-25 15:56:07 +00:00
context.DispatchFile(file)
2016-01-10 11:17:35 +00:00
}
2021-04-12 02:13:59 +00:00
return nil
2016-01-10 11:17:35 +00:00
}