// Writes data to LZMA2 stream. Note that written data will be buffered.
// Use Flush or Close to ensure that data is written to the underlying
// writer.
Writes data to LZMA2 stream. Note that written data will be buffered.
Use Flush or Close to ensure that data is written to the underlying
writer.
// Writes data to LZMA2 stream . Note that written data will be buffered . // Use Flush or Close to ensure that data is written to the underlying // writer .
func (w *Writer2) Write(p []byte) (n int, err error) {
	if w.cstate == stop {
		return 0, errClosed
	}
	for n < len(p) {
		m := maxUncompressed - w.written()
		if m <= 0 {
			panic("lzma: maxUncompressed reached")
		}
		var q []byte
		if n+m < len(p) {
			q = p[n : n+m]
		} else {
			q = p[n:]
		}
		k, err := w.encoder.Write(q)
		n += k
		if err != nil && err != ErrLimit {
			return n, err
		}
		if err == ErrLimit || k == m {
			if err = w.flushChunk(); err != nil {
				return n, err
			}
		}
	}
	return n, nil
}
func ( w * Writer2 ) Write ( p [ ] byte ) ( n int , err error ) { if w . cstate == stop { return 0 , errClosed } for n < len ( p ) { m := maxUncompressed - w . written ( ) if m <= 0 { panic ( " " ) } var q [ ] byte if n + m < len ( p ) { q = p [ n : n + m ] } else { q = p [ n : ] } k , err := w . encoder . Write ( q ) n += k if err != nil && err != ErrLimit { return n , err } if err == ErrLimit || k == m { if err = w . flushChunk ( ) ; err != nil { return n , err } } } return n , nil }
Writes data to LZMA2 stream.
Writes data to LZMA2 stream .