-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
Thanks for a great package!
I end up needing to have an external func to automatically decode a binary or XML plist, see below.
It would be nice to replace the deprecated plist.NewDecoder func with this. Happy to provide a PR on your suggestion.
// NewPListDecoder returns a new Property List decoder, auto-detecting
// whether it is binary or XML text.
func NewPListDecoder(r io.ReadSeeker) *plist.Decoder {
// Detect if it XML or Binary
magic := make([]byte, 5)
n, err := r.Read(magic)
if err != nil {
return nil
}
_, err = r.Seek(0, 0)
if err != nil {
return nil
}
switch string(magic[:n]) {
case "<?xml":
return plist.NewXMLDecoder(r)
case "bplis":
return plist.NewBinaryDecoder(r)
}
return nil
}