| 24 | } |
| 25 | |
| 26 | func (f basePathFetcher) File(pathElements ...string) ([]byte, error) { |
| 27 | if len(pathElements) == 0 { |
| 28 | return nil, errFilenameNotSpecified.New() |
| 29 | } |
| 30 | |
| 31 | // NOTE: filepath.IsAbs returns true for paths starting with '/' on all supported operating systems. |
| 32 | if filepath.IsAbs(pathElements[0]) { |
| 33 | return f.Interface.File(pathElements...) |
| 34 | } |
| 35 | return f.Interface.File(append(f.basePath, pathElements...)...) |
| 36 | } |
| 37 | |
| 38 | // WithBasePath returns an Interface, which preprends basePath to non-absolute requested paths. |
| 39 | func WithBasePath(f Interface, basePath ...string) Interface { |