-
Notifications
You must be signed in to change notification settings - Fork 0
/
ufid.go
55 lines (40 loc) · 939 Bytes
/
ufid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package id3
import (
"encoding/hex"
"fmt"
"golang.org/x/text/encoding/charmap"
)
type UniqueFileIDFrame struct {
frameBase
owner string
uniqueID []byte
}
func newUniqueFileIDFrame(tag *Tag, header *frameHeader, data []byte) (Frame, error) {
uidf := &UniqueFileIDFrame{}
uidf.header = header
l := len(data)
var err error
owner, i, err := trimForEncoding(l, data, ISO88591, true)
if err != nil {
return nil, err
}
i++
uidf.owner, err = decodeString(owner, charmap.Windows1252)
if err != nil {
return nil, err
}
uidf.uniqueID = data[i:]
return uidf, nil
}
func (uidf *UniqueFileIDFrame) String() string {
return fmt.Sprintf("%v (%v)", hex.EncodeToString(uidf.uniqueID), uidf.owner)
}
func (uidf *UniqueFileIDFrame) Bytes() []byte {
return uidf.uniqueID
}
func (uidf *UniqueFileIDFrame) Owner() string {
return uidf.owner
}
func (uidf *UniqueFileIDFrame) UniqueID() []byte {
return uidf.uniqueID
}