Add padding field to tag

develop
Michael Yang 2013-12-30 01:40:22 -05:00
rodzic 9ddb65c5a1
commit 402ce1b83b
1 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -14,17 +14,19 @@ const (
type Tag struct {
Header
Frames map[string][]Framer
Frames map[string][]Framer
padding uint
}
func NewTag(reader io.Reader) *Tag {
t := &Tag{NewHeader(reader), make(map[string][]Framer)}
t := &Tag{NewHeader(reader), make(map[string][]Framer), 0}
if t.Header == nil {
return nil
}
var frame Framer
for size := t.Header.Size(); size > 0; {
size := t.Header.Size()
for size > 0 {
switch t.Header.Version() {
case "2.3.0":
frame = NewV3Frame(reader)
@ -42,6 +44,12 @@ func NewTag(reader io.Reader) *Tag {
size -= FrameHeaderSize + frame.Size()
}
t.padding = uint(size)
nAdvance := int(t.padding - FrameHeaderSize)
if n, err := io.ReadFull(reader, make([]byte, nAdvance)); n != nAdvance || err != nil {
return nil
}
return t
}