MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / loadItemsFromFS

Function loadItemsFromFS

internal/items/plugin.go:45–66  ·  view source on GitHub ↗
(subFS fs.ReadFileFS, dst map[int]*ItemSpec)

Source from the content-addressed store, hash-verified

43}
44
45func loadItemsFromFS(subFS fs.ReadFileFS, dst map[int]*ItemSpec) {
46 // PluginFiles does not support directory traversal, so use KnownPaths
47 // when available to enumerate files directly.
48 if pl, ok := subFS.(fileloader.PathLister); ok {
49 for _, path := range pl.KnownPaths() {
50 if !strings.HasPrefix(path, `items/`) || !strings.HasSuffix(path, `.yaml`) {
51 continue
52 }
53 loadItemFileFromFS(subFS, path, dst)
54 }
55 return
56 }
57
58 // Fallback: standard directory walk for FSes that support it.
59 _ = fs.WalkDir(subFS, `items`, func(path string, d fs.DirEntry, err error) error {
60 if err != nil || d.IsDir() || !strings.HasSuffix(path, `.yaml`) {
61 return nil
62 }
63 loadItemFileFromFS(subFS, path, dst)
64 return nil
65 })
66}
67
68func loadItemFileFromFS(subFS fs.ReadFileFS, path string, dst map[int]*ItemSpec) {
69 b, err := subFS.ReadFile(path)

Callers 1

loadPluginItemsFunction · 0.85

Calls 2

loadItemFileFromFSFunction · 0.85
KnownPathsMethod · 0.65

Tested by

no test coverage detected