github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/builder/dockerfile/internals_unix.go (about) 1 // +build !windows 2 3 package dockerfile 4 5 import ( 6 "os" 7 "path/filepath" 8 "strings" 9 10 "github.com/docker/docker/pkg/system" 11 ) 12 13 // normaliseDest normalises the destination of a COPY/ADD command in a 14 // platform semantically consistent way. 15 func normaliseDest(cmdName, workingDir, requested string) (string, error) { 16 dest := filepath.FromSlash(requested) 17 endsInSlash := strings.HasSuffix(requested, string(os.PathSeparator)) 18 if !system.IsAbs(requested) { 19 dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(workingDir), dest) 20 // Make sure we preserve any trailing slash 21 if endsInSlash { 22 dest += string(os.PathSeparator) 23 } 24 } 25 return dest, nil 26 } 27 28 func containsWildcards(name string) bool { 29 for i := 0; i < len(name); i++ { 30 ch := name[i] 31 if ch == '\\' { 32 i++ 33 } else if ch == '*' || ch == '?' || ch == '[' { 34 return true 35 } 36 } 37 return false 38 }