aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-10-14 18:07:17 +0200
committern-peugnet <n.peugnet@free.fr>2021-10-15 16:11:43 +0200
commit89fb0a85f78a415477e450b0091d8c2b994b687d (patch)
treeee8283bd91998b65f1a5056f254467a616964653 /utils
parent347c626f4103f7afd494031cdf9f9fa7868f8e59 (diff)
downloaddna-backup-89fb0a85f78a415477e450b0091d8c2b994b687d.tar.gz
dna-backup-89fb0a85f78a415477e450b0091d8c2b994b687d.zip
start dir exporter
Diffstat (limited to 'utils')
-rw-r--r--utils/io.go19
1 files changed, 19 insertions, 0 deletions
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
+}