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

Method ReadBytes

internal/plugins/plugins.go:416–433  ·  view source on GitHub ↗
(identifier string)

Source from the content-addressed store, hash-verified

414}
415
416func (p *Plugin) ReadBytes(identifier string) ([]byte, error) {
417
418 // Fix up identifier
419 fileName := strings.ToLower(txtCleanRegex.ReplaceAllString(identifier, "-")) + `.plugin.dat`
420
421 // Fix up folderpath
422 folderPath := util.FilePath(writeFolderPath, `/`, strings.ToLower(txtCleanRegex.ReplaceAllString(fmt.Sprintf(`%s-v%s`, p.name, p.version), "-")))
423
424 // Create full path
425 fullPath := util.FilePath(folderPath, `/`, fileName)
426
427 bytes, err := util.ReadFile(fullPath)
428 if err != nil && !os.IsNotExist(err) {
429 mudlog.Warn(`plugin.ReadBytes`, `name`, p.name, `path`, fullPath, `error`, err)
430 }
431
432 return bytes, err
433}
434
435func (p *Plugin) WriteStruct(identifier string, in any) error {
436

Calls 3

FilePathFunction · 0.92
ReadFileFunction · 0.92
WarnFunction · 0.92