internals_unix.go 961 B

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