MCPcopy
hub / github.com/hashicorp/go-getter / Decompress

Method Decompress

decompress_zstd.go:20–46  ·  view source on GitHub ↗
(dst, src string, dir bool, umask os.FileMode)

Source from the content-addressed store, hash-verified

18}
19
20func (d *ZstdDecompressor) Decompress(dst, src string, dir bool, umask os.FileMode) error {
21 if dir {
22 return fmt.Errorf("zstd-compressed files can only unarchive to a single file")
23 }
24
25 // If we're going into a directory we should make that first
26 if err := os.MkdirAll(filepath.Dir(dst), mode(0755, umask)); err != nil {
27 return err
28 }
29
30 // File first
31 f, err := os.Open(src)
32 if err != nil {
33 return err
34 }
35 defer f.Close()
36
37 // zstd compression is second
38 zstdR, err := zstd.NewReader(f)
39 if err != nil {
40 return err
41 }
42 defer zstdR.Close()
43
44 // Copy it out, potentially using a file size limit.
45 return copyReader(dst, zstdR, 0622, umask, d.FileSizeLimit)
46}

Callers

nothing calls this directly

Calls 4

modeFunction · 0.85
copyReaderFunction · 0.85
DirMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected