fix: Ensure that full records are written to tape so that EOF marks work

This commit is contained in:
Felicitas Pojtinger
2021-11-21 19:14:47 +01:00
parent 7681c5517e
commit 5bf40bf7cb
4 changed files with 76 additions and 20 deletions
+31
View File
@@ -0,0 +1,31 @@
package counters
import "io"
type CounterReader struct {
Reader io.Reader
BytesRead int
}
func (r *CounterReader) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
r.BytesRead += n
return n, err
}
type CounterWriter struct {
Writer io.Writer
BytesRead int
}
func (w *CounterWriter) Write(p []byte) (n int, err error) {
n, err = w.Writer.Write(p)
w.BytesRead += n
return n, err
}
-17
View File
@@ -1,17 +0,0 @@
package readers
import "io"
type Counter struct {
Reader io.Reader
BytesRead int
}
func (r *Counter) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
r.BytesRead += n
return n, err
}