MCPcopy
hub / github.com/rclone/rclone / JoinRootPath

Function JoinRootPath

fs/fspath/path.go:330–356  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

328//
329// If the path contains \ these will be converted to / on Windows.
330func 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}

Callers 15

NewFsFunction · 0.92
NewFunction · 0.92
NewFsFunction · 0.92
dbDumpMethod · 0.92
NewFsFunction · 0.92
NewFsFunction · 0.92
NewFsFunction · 0.92
NewFsFunction · 0.92
deriveFsFunction · 0.92
NewFsFunction · 0.92
checkBase32768Method · 0.92
deleteSingleMethod · 0.92

Calls 3

makeAbsoluteFunction · 0.85
ParseFunction · 0.85
JoinMethod · 0.80

Tested by 2

deriveFsFunction · 0.74
TestJoinRootPathFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…