JoinRootPath joins filePath onto remote If the remote has a leading "//" this is preserved to allow Windows network paths to be used as remotes. If filePath is empty then remote will be returned. If the path contains \ these will be converted to / on Windows.
(remote, filePath string)
| 328 | // |
| 329 | // If the path contains \ these will be converted to / on Windows. |
| 330 | func JoinRootPath(remote, filePath string) string { |
| 331 | remote = filepath.ToSlash(remote) |
| 332 | if filePath == "" { |
| 333 | return remote |
| 334 | } |
| 335 | filePath = filepath.ToSlash(filePath) |
| 336 | filePath = makeAbsolute(filePath) |
| 337 | if strings.HasPrefix(remote, "//") { |
| 338 | return "/" + path.Join(remote, filePath) |
| 339 | } |
| 340 | parsed, err := Parse(remote) |
| 341 | remoteName, remotePath := parsed.ConfigString, parsed.Path |
| 342 | if err != nil { |
| 343 | // Couldn't parse so assume it is a path |
| 344 | remoteName = "" |
| 345 | remotePath = remote |
| 346 | } |
| 347 | remotePath = path.Join(remotePath, filePath) |
| 348 | if remoteName != "" { |
| 349 | remoteName += ":" |
| 350 | // if have remote: then normalise the remotePath |
| 351 | if remotePath == "." { |
| 352 | remotePath = "" |
| 353 | } |
| 354 | } |
| 355 | return remoteName + remotePath |
| 356 | } |
searching dependent graphs…