aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go66
1 files changed, 0 insertions, 66 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go
deleted file mode 100644
index ccc7f9c..0000000
--- a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go
+++ /dev/null
@@ -1,66 +0,0 @@
1package ioutils
2
3import "io"
4
5// NopWriter represents a type which write operation is nop.
6type NopWriter struct{}
7
8func (*NopWriter) Write(buf []byte) (int, error) {
9 return len(buf), nil
10}
11
12type nopWriteCloser struct {
13 io.Writer
14}
15
16func (w *nopWriteCloser) Close() error { return nil }
17
18// NopWriteCloser returns a nopWriteCloser.
19func NopWriteCloser(w io.Writer) io.WriteCloser {
20 return &nopWriteCloser{w}
21}
22
23// NopFlusher represents a type which flush operation is nop.
24type NopFlusher struct{}
25
26// Flush is a nop operation.
27func (f *NopFlusher) Flush() {}
28
29type writeCloserWrapper struct {
30 io.Writer
31 closer func() error
32}
33
34func (r *writeCloserWrapper) Close() error {
35 return r.closer()
36}
37
38// NewWriteCloserWrapper returns a new io.WriteCloser.
39func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser {
40 return &writeCloserWrapper{
41 Writer: r,
42 closer: closer,
43 }
44}
45
46// WriteCounter wraps a concrete io.Writer and hold a count of the number
47// of bytes written to the writer during a "session".
48// This can be convenient when write return is masked
49// (e.g., json.Encoder.Encode())
50type WriteCounter struct {
51 Count int64
52 Writer io.Writer
53}
54
55// NewWriteCounter returns a new WriteCounter.
56func NewWriteCounter(w io.Writer) *WriteCounter {
57 return &WriteCounter{
58 Writer: w,
59 }
60}
61
62func (wc *WriteCounter) Write(p []byte) (count int, err error) {
63 count, err = wc.Writer.Write(p)
64 wc.Count += int64(count)
65 return
66}