github.com/rish1988/moby@v25.0.2+incompatible/pkg/chrootarchive/diff_windows.go (about) 1 package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive" 2 3 import ( 4 "fmt" 5 "io" 6 "path/filepath" 7 8 "github.com/docker/docker/pkg/archive" 9 "github.com/docker/docker/pkg/longpath" 10 ) 11 12 // applyLayerHandler parses a diff in the standard layer format from `layer`, and 13 // applies it to the directory `dest`. Returns the size in bytes of the 14 // contents of the layer. 15 func applyLayerHandler(dest string, layer io.Reader, options *archive.TarOptions, decompress bool) (size int64, err error) { 16 dest = filepath.Clean(dest) 17 18 // Ensure it is a Windows-style volume path 19 dest = longpath.AddPrefix(dest) 20 21 if decompress { 22 decompressed, err := archive.DecompressStream(layer) 23 if err != nil { 24 return 0, err 25 } 26 defer decompressed.Close() 27 28 layer = decompressed 29 } 30 31 s, err := archive.UnpackLayer(dest, layer, nil) 32 if err != nil { 33 return 0, fmt.Errorf("ApplyLayer %s failed UnpackLayer to %s: %s", layer, dest, err) 34 } 35 36 return s, nil 37 }