12 "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath"
15 // fixVolumePathPrefix does platform specific processing to ensure that if
16 // the path being passed in is not in a volume path format, convert it to one.
17 func fixVolumePathPrefix(srcPath string) string {
18 return longpath.AddPrefix(srcPath)
21 // getWalkRoot calculates the root path when performing a TarWithOptions.
22 // We use a separate function as this is platform specific.
23 func getWalkRoot(srcPath string, include string) string {
24 return filepath.Join(srcPath, include)
27 // CanonicalTarNameForPath returns platform-specific filepath
28 // to canonical posix-style path for tar archival. p is relative
30 func CanonicalTarNameForPath(p string) (string, error) {
31 // windows: convert windows style relative path with backslashes
32 // into forward slashes. Since windows does not allow '/' or '\'
33 // in file names, it is mostly safe to replace however we must
35 if strings.Contains(p, "/") {
36 return "", fmt.Errorf("Windows path contains forward slash: %s", p)
38 return strings.Replace(p, string(os.PathSeparator), "/", -1), nil
42 // chmodTarEntry is used to adjust the file permissions used in tar header based
43 // on the platform the archival is done.
44 func chmodTarEntry(perm os.FileMode) os.FileMode {
46 // Add the x bit: make everything +x from windows
52 func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (inode uint64, err error) {
53 // do nothing. no notion of Rdev, Inode, Nlink in stat on Windows
57 // handleTarTypeBlockCharFifo is an OS-specific helper function used by
58 // createTarFile to handle the following types of header: Block; Char; Fifo
59 func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
63 func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
67 func getFileUIDGID(stat interface{}) (int, int, error) {
68 // no notion of file ownership mapping yet on Windows