added some new API calls

mainly around getting the file size and data read for convenience for
other tools
This commit is contained in:
2026-09-16 23:47:35 +01:00
parent 137b96fae6
commit 312d979be1
9 changed files with 81 additions and 7 deletions
+19
View File
@@ -6,10 +6,15 @@ import (
"unsafe"
)
type Sizer interface {
Size() int64
}
type GobReader struct {
TotalRead int64
File *os.File
Buf []byte
size int64
}
func NewOgBinReader(fp string) *GobReader {
@@ -18,10 +23,16 @@ func NewOgBinReader(fp string) *GobReader {
return nil
}
info, err := bin.Stat()
if err != nil {
return nil
}
return &GobReader{
TotalRead: 0,
File: bin,
Buf: make([]byte, unsafe.Sizeof(Outgauge{})),
size: info.Size(),
}
}
@@ -55,3 +66,11 @@ func (g *GobReader) Next(buffer []byte) (int, error) {
return nBytes, nil
}
func (g *GobReader) GetTotalRead() int64 {
return g.TotalRead
}
func (g *GobReader) Size() int64 {
return g.size
}