-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnop_sink.go
65 lines (47 loc) · 1.1 KB
/
nop_sink.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package savior
import (
"path/filepath"
"github.com/itchio/headway/state"
)
// NopSink does not write anything anywhere
type NopSink struct {
Directory string
Consumer *state.Consumer
writer *nopEntryWriter
}
var _ Sink = (*NopSink)(nil)
func (ns *NopSink) destPath(entry *Entry) string {
return filepath.Join(ns.Directory, filepath.FromSlash(entry.CanonicalPath))
}
func (ns *NopSink) Mkdir(entry *Entry) error {
return nil
}
func (ns *NopSink) GetWriter(entry *Entry) (EntryWriter, error) {
return NewNopEntryWriter(), nil
}
func (ns *NopSink) Preallocate(entry *Entry) error {
return nil
}
func (ns *NopSink) Symlink(entry *Entry, linkname string) error {
return nil
}
func (ns *NopSink) Nuke() error {
return nil
}
func (ns *NopSink) Close() error {
return nil
}
type nopEntryWriter struct{}
var _ EntryWriter = (*nopEntryWriter)(nil)
func NewNopEntryWriter() EntryWriter {
return &nopEntryWriter{}
}
func (ew *nopEntryWriter) Write(buf []byte) (int, error) {
return len(buf), nil
}
func (ew *nopEntryWriter) Close() error {
return nil
}
func (ew *nopEntryWriter) Sync() error {
return nil
}