Writeable returns a writeable Path
(cheatpaths []Path)
| 6 | |
| 7 | // Writeable returns a writeable Path |
| 8 | func Writeable(cheatpaths []Path) (Path, error) { |
| 9 | |
| 10 | // iterate backwards over the cheatpaths |
| 11 | // NB: we're going backwards because we assume that the most "local" |
| 12 | // cheatpath will be specified last in the configs |
| 13 | for i := len(cheatpaths) - 1; i >= 0; i-- { |
| 14 | // if the cheatpath is not read-only, it is writeable, and thus returned |
| 15 | if !cheatpaths[i].ReadOnly { |
| 16 | return cheatpaths[i], nil |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // otherwise, return an error |
| 21 | return Path{}, fmt.Errorf("no writeable cheatpaths found") |
| 22 | } |
no outgoing calls