refactor: code cleaning

This commit is contained in:
Unlock Music Dev
2022-11-20 02:47:28 +08:00
parent 8e068b9c8d
commit f6748d644d
7 changed files with 41 additions and 30 deletions

View File

@@ -8,17 +8,20 @@ import (
)
type Decoder struct {
header header
cipher common.StreamDecoder
rd io.ReadSeeker
rd io.ReadSeeker
cipher common.StreamDecoder
offset int
header header
}
func NewDecoder(rd io.ReadSeeker) common.Decoder {
return &Decoder{rd: rd}
}
// Validate checks if the file is a valid Kugou (.kgm, .vpr, .kgma) file.
// rd will be seeked to the beginning of the encrypted audio.
func (d *Decoder) Validate() (err error) {
if err := d.header.FromFile(d.rd); err != nil {
return err