forked from mirrors/tar-split
archive/tar: a []byte copy needed for GNU LongLink
This commit is contained in:
parent
9b9df04f1f
commit
4d66163297
1 changed files with 10 additions and 22 deletions
|
@ -154,60 +154,48 @@ func (tr *Reader) Next() (*Header, error) {
|
||||||
}
|
}
|
||||||
return hdr, nil
|
return hdr, nil
|
||||||
case TypeGNULongName:
|
case TypeGNULongName:
|
||||||
var b *bytes.Buffer
|
|
||||||
if tr.RawAccounting {
|
|
||||||
b = bytes.NewBuffer(tr.RawBytes())
|
|
||||||
}
|
|
||||||
// We have a GNU long name header. Its contents are the real file name.
|
// We have a GNU long name header. Its contents are the real file name.
|
||||||
realname, err := ioutil.ReadAll(tr)
|
realname, err := ioutil.ReadAll(tr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var buf []byte
|
||||||
if tr.RawAccounting {
|
if tr.RawAccounting {
|
||||||
if _, err = tr.rawBytes.Write(b.Bytes()); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if _, err = tr.rawBytes.Write(realname); err != nil {
|
if _, err = tr.rawBytes.Write(realname); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
b.Reset()
|
buf = make([]byte, tr.rawBytes.Len())
|
||||||
b.Write(tr.RawBytes())
|
copy(buf[:], tr.RawBytes())
|
||||||
}
|
}
|
||||||
hdr, err := tr.Next()
|
hdr, err := tr.Next()
|
||||||
// since the above call to Next() resets the buffer, we need to throw the bytes over
|
// since the above call to Next() resets the buffer, we need to throw the bytes over
|
||||||
if tr.RawAccounting {
|
if tr.RawAccounting {
|
||||||
b.Write(tr.RawBytes())
|
buf = append(buf, tr.RawBytes()...)
|
||||||
if _, err = tr.rawBytes.Write(b.Bytes()); err != nil {
|
if _, err = tr.rawBytes.Write(buf); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hdr.Name = cString(realname)
|
hdr.Name = cString(realname)
|
||||||
return hdr, err
|
return hdr, err
|
||||||
case TypeGNULongLink:
|
case TypeGNULongLink:
|
||||||
var b *bytes.Buffer
|
|
||||||
if tr.RawAccounting {
|
|
||||||
b = bytes.NewBuffer(tr.RawBytes())
|
|
||||||
}
|
|
||||||
// We have a GNU long link header.
|
// We have a GNU long link header.
|
||||||
realname, err := ioutil.ReadAll(tr)
|
realname, err := ioutil.ReadAll(tr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var buf []byte
|
||||||
if tr.RawAccounting {
|
if tr.RawAccounting {
|
||||||
if _, err = tr.rawBytes.Write(b.Bytes()); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if _, err = tr.rawBytes.Write(realname); err != nil {
|
if _, err = tr.rawBytes.Write(realname); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
b.Reset()
|
buf = make([]byte, tr.rawBytes.Len())
|
||||||
b.Write(tr.RawBytes())
|
copy(buf[:], tr.RawBytes())
|
||||||
}
|
}
|
||||||
hdr, err := tr.Next()
|
hdr, err := tr.Next()
|
||||||
// since the above call to Next() resets the buffer, we need to throw the bytes over
|
// since the above call to Next() resets the buffer, we need to throw the bytes over
|
||||||
if tr.RawAccounting {
|
if tr.RawAccounting {
|
||||||
b.Write(tr.RawBytes())
|
buf = append(buf, tr.RawBytes()...)
|
||||||
if _, err = tr.rawBytes.Write(b.Bytes()); err != nil {
|
if _, err = tr.rawBytes.Write(buf); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue