11 // Bzip2Decompressor is an implementation of Decompressor that can
12 // decompress bz2 files.
13 type Bzip2Decompressor struct{}
15 func (d *Bzip2Decompressor) Decompress(dst, src string, dir bool) error {
16 // Directory isn't supported at all
18 return fmt.Errorf("bzip2-compressed files can only unarchive to a single file")
21 // If we're going into a directory we should make that first
22 if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
27 f, err := os.Open(src)
33 // Bzip2 compression is second
34 bzipR := bzip2.NewReader(f)
37 dstF, err := os.Create(dst)
43 _, err = io.Copy(dstF, bzipR)