added some new API calls
mainly around getting the file size and data read for convenience for other tools
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user