Beispiel #1
0
// Work distrubutes and manages the work. If any processing results in an
// error, the errCnt is incremented and a ErrProcess is returned. For more
// details the errs map can be checked. The key for the errs map is the
// filename that had the error.
//
// For compression operations, if the format specified is unknown or not
// supported, either compress.Unknown or a peu.Unsupported error will be
// returned.
func (w *Worker) Work() error {
	// make sure concurrency is at least 1
	if w.concurrency < 1 {
		w.concurrency = 1
	}
	if w.decompress {
		return w.Decompress()
	}
	w.Format = compress.ParseFormat(w.format)
	return w.Compress()
}
Beispiel #2
0
Datei: c.go Projekt: mohae/peu
// Compress is the handler for compression. Bytes read is returned along with
// any non io.EOF error that may have occurred.
func Compress(format string, r io.Reader, w io.Writer) (int64, error) {
	if format == "" {
		return 0, ErrNoFormat
	}
	f := compress.ParseFormat(format)
	switch f {
	case compress.LZ4:
		return CompressLZ4(r, w)
	case compress.GZip:
		return CompressGZip(r, w)
	default:
		return 0, ErrUnsupported
	}
}