check header again
parent
6151a1a0cc
commit
8c53711fbe
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
type parser struct {
|
||||
// the source of replay bytes. Must NOT be compressed.
|
||||
source io.Reader
|
||||
}
|
||||
|
||||
func newParser(r io.Reader) *parser {
|
||||
return &parser{source: r}
|
||||
}
|
||||
|
||||
// checks whether we have an acceptable header at the current reader position.
|
||||
func (p *parser) checkHeader() (bool, error) {
|
||||
buf := make([]byte, 8)
|
||||
if _, err := p.source.Read(buf); err != nil {
|
||||
return false, fmt.Errorf("unable to read header bytes: %v", err)
|
||||
}
|
||||
return string(buf) == replay_header, nil
|
||||
}
|
Loading…
Reference in New Issue