aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-getter/decompress_txz.go
diff options
context:
space:
mode:
authorAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
committerAlex Pilon <apilon@hashicorp.com>2019-02-22 18:24:37 -0500
commit15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch)
tree255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/go-getter/decompress_txz.go
parent07971ca38143c5faf951d152fba370ddcbe26ad5 (diff)
downloadterraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst
terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/decompress_txz.go')
-rw-r--r--vendor/github.com/hashicorp/go-getter/decompress_txz.go39
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 @@
1package getter
2
3import (
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.
13type TarXzDecompressor struct{}
14
15func (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}