splitPath splits a path using "/" as separator into its components. The first item has its initial path separator kept.
(p string)
| 961 | // |
| 962 | // The first item has its initial path separator kept. |
| 963 | func splitPath(p string) []string { |
| 964 | if p == "" { |
| 965 | return nil |
| 966 | } |
| 967 | var out []string |
| 968 | s := "" |
| 969 | for _, c := range p { |
| 970 | if c != '/' || (len(out) == 0 && strings.Count(s, "/") == len(s)) { |
| 971 | s += string(c) |
| 972 | } else if s != "" { |
| 973 | out = append(out, s) |
| 974 | s = "" |
| 975 | } |
| 976 | } |
| 977 | if s != "" { |
| 978 | out = append(out, s) |
| 979 | } |
| 980 | return out |
| 981 | } |
| 982 | |
| 983 | // isFile returns true if the path is a valid file. |
| 984 | func isFile(p string) bool { |
no outgoing calls
searching dependent graphs…