-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.go
More file actions
46 lines (38 loc) · 937 Bytes
/
Copy pathio.go
File metadata and controls
46 lines (38 loc) · 937 Bytes
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
package fs
import "io"
// Pather is the interface that wraps the Path method.
//
// Path returns the native filesystem path for this resource.
type Pather interface {
Path() string
}
// ReadPathCloser is the interface that groups the Read, Path, and Close
// methods.
type ReadPathCloser interface {
io.Reader
Pather
io.Closer
}
// WritePathCloser is the interface that groups the Write, Path, and Close
// methods.
type WritePathCloser interface {
io.Writer
Pather
io.Closer
}
type pather string
func (p pather) Path() string { return string(p) }
// readPathCloser composes an io.ReadCloser with a path.
func readPathCloser(rc io.ReadCloser, p string) ReadPathCloser {
return struct {
io.ReadCloser
pather
}{rc, pather(p)}
}
// writePathCloser composes an io.WriteCloser with a path.
func writePathCloser(wc io.WriteCloser, p string) WritePathCloser {
return struct {
io.WriteCloser
pather
}{wc, pather(p)}
}