ResolveSavePath resolves a relative path to a validated absolute path via FileIO.ResolvePath. It returns an error if no FileIO provider is registered or if the path fails validation (e.g. traversal, symlink escape).
(path string)
| 571 | // FileIO.ResolvePath. It returns an error if no FileIO provider is registered |
| 572 | // or if the path fails validation (e.g. traversal, symlink escape). |
| 573 | func (ctx *RuntimeContext) ResolveSavePath(path string) (string, error) { |
| 574 | fio := ctx.FileIO() |
| 575 | if fio == nil { |
| 576 | return "", fmt.Errorf("no file I/O provider registered") |
| 577 | } |
| 578 | resolved, err := fio.ResolvePath(path) |
| 579 | if err != nil { |
| 580 | return "", fmt.Errorf("resolve save path: %w", err) |
| 581 | } |
| 582 | if resolved == "" { |
| 583 | return "", fmt.Errorf("resolve save path: empty result for %q", path) |
| 584 | } |
| 585 | return resolved, nil |
| 586 | } |
| 587 | |
| 588 | // WrapOpenError matches a FileIO.Open/Stat error and wraps it with the |
| 589 | // caller-provided message prefix. |
no test coverage detected