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