| 414 | } |
| 415 | |
| 416 | func (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 | |
| 435 | func (p *Plugin) WriteStruct(identifier string, in any) error { |
| 436 | |