github.com/lafolle/docker@v1.6.0/pkg/archive/archive_windows.go (about) 1 // +build windows 2 3 package archive 4 5 import ( 6 "fmt" 7 "os" 8 "strings" 9 10 "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" 11 ) 12 13 // canonicalTarNameForPath returns platform-specific filepath 14 // to canonical posix-style path for tar archival. p is relative 15 // path. 16 func CanonicalTarNameForPath(p string) (string, error) { 17 // windows: convert windows style relative path with backslashes 18 // into forward slashes. since windows does not allow '/' or '\' 19 // in file names, it is mostly safe to replace however we must 20 // check just in case 21 if strings.Contains(p, "/") { 22 return "", fmt.Errorf("windows path contains forward slash: %s", p) 23 } 24 return strings.Replace(p, string(os.PathSeparator), "/", -1), nil 25 26 } 27 28 // chmodTarEntry is used to adjust the file permissions used in tar header based 29 // on the platform the archival is done. 30 func chmodTarEntry(perm os.FileMode) os.FileMode { 31 perm &= 0755 32 // Add the x bit: make everything +x from windows 33 perm |= 0111 34 35 return perm 36 } 37 38 func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) { 39 // do nothing. no notion of Rdev, Inode, Nlink in stat on Windows 40 return 41 }