From 89fb0a85f78a415477e450b0091d8c2b994b687d Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 14 Oct 2021 18:07:17 +0200 Subject: start dir exporter --- utils/io.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'utils') diff --git a/utils/io.go b/utils/io.go index a0aa70c..3adc5f2 100644 --- a/utils/io.go +++ b/utils/io.go @@ -54,3 +54,22 @@ func NopReadWrapper(r io.Reader) (io.ReadCloser, error) { func NopWriteWrapper(w io.Writer) io.WriteCloser { return NopCloser(w) } + +type WriteCounter struct { + w io.Writer + count int +} + +func NewWriteCounter(writer io.Writer) *WriteCounter { + return &WriteCounter{w: writer} +} + +func (c *WriteCounter) Write(p []byte) (n int, err error) { + n, err = c.w.Write(p) + c.count += n + return +} + +func (c *WriteCounter) Count() int { + return c.count +} -- cgit v1.2.3