github.com/rumpl/bof@v23.0.0-rc.2+incompatible/pkg/archive/archive_windows.go (about) 1 package archive // import "github.com/docker/docker/pkg/archive" 2 3 import ( 4 "archive/tar" 5 "os" 6 "path/filepath" 7 8 "github.com/docker/docker/pkg/idtools" 9 "github.com/docker/docker/pkg/longpath" 10 ) 11 12 // fixVolumePathPrefix does platform specific processing to ensure that if 13 // the path being passed in is not in a volume path format, convert it to one. 14 func fixVolumePathPrefix(srcPath string) string { 15 return longpath.AddPrefix(srcPath) 16 } 17 18 // getWalkRoot calculates the root path when performing a TarWithOptions. 19 // We use a separate function as this is platform specific. 20 func getWalkRoot(srcPath string, include string) string { 21 return filepath.Join(srcPath, include) 22 } 23 24 // CanonicalTarNameForPath returns platform-specific filepath 25 // to canonical posix-style path for tar archival. p is relative 26 // path. 27 func CanonicalTarNameForPath(p string) string { 28 return filepath.ToSlash(p) 29 } 30 31 // chmodTarEntry is used to adjust the file permissions used in tar header based 32 // on the platform the archival is done. 33 func chmodTarEntry(perm os.FileMode) os.FileMode { 34 // perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.) 35 permPart := perm & os.ModePerm 36 noPermPart := perm &^ os.ModePerm 37 // Add the x bit: make everything +x from windows 38 permPart |= 0111 39 permPart &= 0755 40 41 return noPermPart | permPart 42 } 43 44 func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) (err error) { 45 // do nothing. no notion of Rdev, Nlink in stat on Windows 46 return 47 } 48 49 func getInodeFromStat(stat interface{}) (inode uint64, err error) { 50 // do nothing. no notion of Inode in stat on Windows 51 return 52 } 53 54 // handleTarTypeBlockCharFifo is an OS-specific helper function used by 55 // createTarFile to handle the following types of header: Block; Char; Fifo 56 func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { 57 return nil 58 } 59 60 func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error { 61 return nil 62 } 63 64 func getFileUIDGID(stat interface{}) (idtools.Identity, error) { 65 // no notion of file ownership mapping yet on Windows 66 return idtools.Identity{UID: 0, GID: 0}, nil 67 }