37
38// NewReader creates a new [Reader] reading from r.
39▶func NewReader(r io.Reader) *Reader {
40 return &Reader{r: r, curr: ®FileReader{r, 0}}
41}
· · ·
43// Next advances to the next entry in the tar archive.
44// The Header.Size determines how many bytes can be read for the next file.
45▶// Any remaining data in the current file is automatically discarded.
46// At the end of the archive, Next returns the error io.EOF.
47//
· · ·
53// Programs that want to accept non-local names can ignore
54// the [ErrInsecurePath] error and use the returned header.
55▶func (tr *Reader) Next() (*Header, error) {
56 if tr.err != nil {
57 return nil, tr.err
· · ·
68}
69
70▶func (tr *Reader) next() (*Header, error) {
71 var paxHdrs map[string]string
72 var gnuLongName, gnuLongLink string
· · ·
79 format := FormatUSTAR | FormatPAX | FormatGNU
80 for {
81▶ // Discard the remainder of the file and any padding.
82 if err := discard(tr.r, tr.curr.physicalRemaining()); err != nil {
83 return nil, err
+ 46 more matches in this file