realOSPath replaces path root of p by r if r != "" and returns p otherwise. realOSPath assumes operating system paths and that both paths are cleaned.
(r, p string)
| 63 | // realOSPath replaces path root of p by r if r != "" and returns p otherwise. |
| 64 | // realOSPath assumes operating system paths and that both paths are cleaned. |
| 65 | func realOSPath(r, p string) (string, error) { |
| 66 | if r == "" { |
| 67 | return p, nil |
| 68 | } |
| 69 | if !filepath.IsAbs(p) { |
| 70 | return filepath.Join(r, p), nil |
| 71 | } |
| 72 | if filepath.VolumeName(p) != "" { |
| 73 | return "", errVolumeSpecified.New() |
| 74 | } |
| 75 | return filepath.Join(r, p[1:]), nil |
| 76 | } |
| 77 | |
| 78 | // Interface is an abstraction for file retrieval. |
| 79 | type Interface interface { |