func (tr *Reader) Restore(state []byte) error {
	tr.Reset(tr.r)

	decoder := gob.NewDecoder(bytes.NewReader(state))

	if err := decoder.Decode(&tr.pad); err != nil {
		return err
	}

	var decodeCurr bool
	if err := decoder.Decode(&decodeCurr); err != nil {
		return err
	}

	if decodeCurr {
		var label string
		if err := decoder.Decode(&label); err != nil {
			return err
		}

		switch label {
		case "rfr":
			tr.curr = new(regFileReader)
		case "sfr":
			tr.curr = new(sparseFileReader)
		default:
			return fmt.Errorf("unable to restore numBytesReader with label %q", label)
		}

		if err := decoder.Decode(tr.curr); err != nil {
			return err
		}

		tr.curr.setReader(tr.r)
	}

	return nil
}
// Restore resets this Tar Reader using the given `io.Reader` and
// sets the current file entry position and remaining padding with
// the given serialized state. This Tar Reader can then be used
// to resume reading of an archive after an earlier unexpected EOF
// error, for example. Resuming must begin either at the beginning
// of the next entry header OR in the middle of processing an entry.
// It is not possible to resume in the middle of processing a header.
Restore resets this Tar Reader using the given `io.Reader` and
sets the current file entry position and remaining padding with
the given serialized state. This Tar Reader can then be used
to resume reading of an archive after an earlier unexpected EOF
error, for example. Resuming must begin either at the beginning
of the next entry header OR in the middle of processing an entry.
It is not possible to resume in the middle of processing a header.
// Restore resets this Tar Reader using the given ` io . Reader ` and // sets the current file entry position and remaining padding with // the given serialized state . This Tar Reader can then be used // to resume reading of an archive after an earlier unexpected EOF // error for example . Resuming must begin either at the beginning // of the next entry header OR in the middle of processing an entry . // It is not possible to resume in the middle of processing a header .
func (tr *Reader) Restore(state []byte) error {
	tr.Reset(tr.r)
	decoder := gob.NewDecoder(bytes.NewReader(state))
	if err := decoder.Decode(&tr.pad); err != nil {
		return err
	}
	var decodeCurr bool
	if err := decoder.Decode(&decodeCurr); err != nil {
		return err
	}
	if decodeCurr {
		var label string
		if err := decoder.Decode(&label); err != nil {
			return err
		}
		switch label {
		case "rfr":
			tr.curr = new(regFileReader)
		case "sfr":
			tr.curr = new(sparseFileReader)
		default:
			return fmt.Errorf("unable to restore numBytesReader with label %q", label)
		}
		if err := decoder.Decode(tr.curr); err != nil {
			return err
		}
		tr.curr.setReader(tr.r)
	}
	return nil
}
func ( tr * Reader ) Restore ( state [ ] byte ) error { tr . Reset ( tr . r ) decoder := gob . NewDecoder ( bytes . NewReader ( state ) ) if err := decoder . Decode ( & tr . pad ) ; err != nil { return err } var decodeCurr bool if err := decoder . Decode ( & decodeCurr ) ; err != nil { return err } if decodeCurr { var label string if err := decoder . Decode ( & label ) ; err != nil { return err } switch label { case " " : tr . curr = new ( regFileReader ) case " " : tr . curr = new ( sparseFileReader ) default : return fmt . Errorf ( " " , label ) } if err := decoder . Decode ( tr . curr ) ; err != nil { return err } tr . curr . setReader ( tr . r ) } return nil }
Restore resets this Tar Reader using the given `io.Reader` and
sets the current file entry position and remaining padding with
the given serialized state.
Restore resets this Tar Reader using the given ` io . Reader ` and sets the current file entry position and remaining padding with the given serialized state .