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

Function ValidateOutputPath

cli/command/utils.go:62–85  ·  view source on GitHub ↗

ValidateOutputPath validates the output paths of the "docker cp" command.

(path string)

Source from the content-addressed store, hash-verified

60
61// ValidateOutputPath validates the output paths of the "docker cp" command.
62func ValidateOutputPath(path string) error {
63 dir := filepath.Dir(filepath.Clean(path))
64 if dir != "" && dir != "." {
65 if _, err := os.Stat(dir); os.IsNotExist(err) {
66 return fmt.Errorf("invalid output path: directory %q does not exist", dir)
67 }
68 }
69 // check whether `path` points to a regular file
70 // (if the path exists and doesn't point to a directory)
71 if fileInfo, err := os.Stat(path); !os.IsNotExist(err) {
72 if err != nil {
73 return err
74 }
75
76 if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() {
77 return nil
78 }
79
80 if err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {
81 return fmt.Errorf("invalid output path: %q must be a directory or a regular file: %w", path, err)
82 }
83 }
84 return nil
85}
86
87// ValidateOutputPathFileMode validates the output paths of the "docker cp" command
88// and serves as a helper to [ValidateOutputPath]

Callers

nothing calls this directly

Calls 2

ModeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…