示例#1
0
//Returns the lzma-decompressed bytes
func shortdecompress(shrunk []byte) []byte {
	b := bytes.NewBuffer(shrunk)
	r := lzma.NewReader(b)
	var bb bytes.Buffer
	io.Copy(&bb, r)
	r.Close()
	return bb.Bytes()
}
示例#2
0
func ReadInfoFile(file string, out chan<- InfoRecord) error {
	if _, err := os.Stat(file); os.IsNotExist(err) {
		return nil
	}

	f, err := os.Open(file)
	if err != nil {
		return err
	}
	defer f.Close()

	lz := lzma.NewReader(f)
	defer lz.Close()

	buf, err := ioutil.ReadAll(lz)
	if err != nil {
		return err
	}

	var wg sync.WaitGroup
	sz := len(buf)
	for i := 0; i < sz; i += chankSize {
		to := i + chankSize
		if to > sz {
			to = sz
		}

		wg.Add(1)
		go func(f int, t int) {
			defer wg.Done()
			err = extractInfo(buf, f, t, out)
		}(i, to)
	}

	wg.Wait()
	return nil
}
示例#3
0
func Decompress(in io.Reader) io.Reader {
	return lzma.NewReader(in)
}