mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
32 lines
526 B
Go
32 lines
526 B
Go
// Copyright 2014 The kv Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package kv
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
)
|
|
|
|
type header struct {
|
|
magic []byte
|
|
ver byte
|
|
reserved []byte
|
|
}
|
|
|
|
func (h *header) rd(b []byte) error {
|
|
if len(b) != 16 {
|
|
panic("internal error")
|
|
}
|
|
|
|
if h.magic = b[:4]; !bytes.Equal(h.magic, []byte(magic)) {
|
|
return fmt.Errorf("Unknown file format")
|
|
}
|
|
|
|
b = b[4:]
|
|
h.ver = b[0]
|
|
h.reserved = b[1:]
|
|
return nil
|
|
}
|