FileIO resolves the FileIO using the current execution context. Falls back to the globally registered provider when Factory or its FileIOProvider is nil (e.g. in lightweight test helpers).
()
| 552 | // Falls back to the globally registered provider when Factory or its |
| 553 | // FileIOProvider is nil (e.g. in lightweight test helpers). |
| 554 | func (ctx *RuntimeContext) FileIO() fileio.FileIO { |
| 555 | if ctx != nil && ctx.Factory != nil { |
| 556 | if fio := ctx.Factory.ResolveFileIO(ctx.ctx); fio != nil { |
| 557 | return fio |
| 558 | } |
| 559 | } |
| 560 | if p := fileio.GetProvider(); p != nil { |
| 561 | c := context.Background() |
| 562 | if ctx != nil { |
| 563 | c = ctx.ctx |
| 564 | } |
| 565 | return p.ResolveFileIO(c) |
| 566 | } |
| 567 | return nil |
| 568 | } |
| 569 | |
| 570 | // ResolveSavePath resolves a relative path to a validated absolute path via |
| 571 | // FileIO.ResolvePath. It returns an error if no FileIO provider is registered |