2023-10-13 09:43:27 +00:00
|
|
|
package change
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"io"
|
2023-10-16 08:50:19 +00:00
|
|
|
|
2023-10-13 09:43:27 +00:00
|
|
|
"git.crumpington.com/public/jldb/lib/errs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func writeBin(w io.Writer, data ...any) error {
|
|
|
|
for _, value := range data {
|
|
|
|
if err := binary.Write(w, binary.LittleEndian, value); err != nil {
|
|
|
|
return errs.IO.WithErr(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func readBin(r io.Reader, ptrs ...any) error {
|
|
|
|
for _, ptr := range ptrs {
|
|
|
|
if err := binary.Read(r, binary.LittleEndian, ptr); err != nil {
|
|
|
|
return errs.IO.WithErr(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|