MCPcopy Index your code
hub / github.com/docker/cli / splitCpArg

Function splitCpArg

cli/command/container/cp.go:502–516  ·  view source on GitHub ↗

We use `:` as a delimiter between CONTAINER and PATH, but `:` could also be in a valid LOCALPATH, like `file:name.txt`. We can resolve this ambiguity by requiring a LOCALPATH with a `:` to be made explicit with a relative or absolute path: `/path/to/file:name.txt` or `./file:name.txt` This is app

(arg string)

Source from the content-addressed store, hash-verified

500// client, a `:` could be part of an absolute Windows path, in which case it
501// is immediately proceeded by a backslash.
502func splitCpArg(arg string) (ctr, path string) {
503 if isAbs(arg) {
504 // Explicit local absolute path, e.g., `C:\foo` or `/foo`.
505 return "", arg
506 }
507
508 ctr, path, ok := strings.Cut(arg, ":")
509 if !ok || strings.HasPrefix(ctr, ".") {
510 // Either there's no `:` in the arg
511 // OR it's an explicit local relative path like `./file:name.txt`.
512 return "", arg
513 }
514
515 return ctr, path
516}
517
518// IsAbs is a platform-agnostic wrapper for filepath.IsAbs.
519//

Callers 2

runCopyFunction · 0.85
TestSplitCpArgFunction · 0.85

Calls 1

isAbsFunction · 0.70

Tested by 1

TestSplitCpArgFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…