diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/decompress_txz.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-getter/decompress_txz.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/decompress_txz.go b/vendor/github.com/hashicorp/go-getter/decompress_txz.go new file mode 100644 index 0000000..5e151c1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/decompress_txz.go | |||
@@ -0,0 +1,39 @@ | |||
1 | package getter | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "os" | ||
6 | "path/filepath" | ||
7 | |||
8 | "github.com/ulikunitz/xz" | ||
9 | ) | ||
10 | |||
11 | // TarXzDecompressor is an implementation of Decompressor that can | ||
12 | // decompress tar.xz files. | ||
13 | type TarXzDecompressor struct{} | ||
14 | |||
15 | func (d *TarXzDecompressor) Decompress(dst, src string, dir bool) error { | ||
16 | // If we're going into a directory we should make that first | ||
17 | mkdir := dst | ||
18 | if !dir { | ||
19 | mkdir = filepath.Dir(dst) | ||
20 | } | ||
21 | if err := os.MkdirAll(mkdir, 0755); err != nil { | ||
22 | return err | ||
23 | } | ||
24 | |||
25 | // File first | ||
26 | f, err := os.Open(src) | ||
27 | if err != nil { | ||
28 | return err | ||
29 | } | ||
30 | defer f.Close() | ||
31 | |||
32 | // xz compression is second | ||
33 | txzR, err := xz.NewReader(f) | ||
34 | if err != nil { | ||
35 | return fmt.Errorf("Error opening an xz reader for %s: %s", src, err) | ||
36 | } | ||
37 | |||
38 | return untar(txzR, dst, src, dir) | ||
39 | } | ||