-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadonlybase.go
50 lines (39 loc) · 1.46 KB
/
readonlybase.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
package fs
import (
"github.com/ungerik/go-fs/fsimpl"
)
// ReadOnlyBase implements the writing methods of the FileSystem interface
// to do nothing and return ErrReadOnlyFileSystem.
// Intended to be used as base for read only file systems,
// so that only the read methods have to be implemented.
type ReadOnlyBase struct{}
func (*ReadOnlyBase) ReadableWritable() (readable, writable bool) {
return true, false
}
// MatchAnyPattern returns true if name matches any of patterns,
// or if len(patterns) == 0.
// The match per pattern works like path.Match or filepath.Match
func (*ReadOnlyBase) MatchAnyPattern(name string, patterns []string) (bool, error) {
return fsimpl.MatchAnyPattern(name, patterns)
}
func (*ReadOnlyBase) SetPermissions(filePath string, perm Permissions) error {
return ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) SetUser(filePath string, user string) error {
return ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) SetGroup(filePath string, group string) error {
return ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) MakeDir(dirPath string, perm []Permissions) error {
return ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) OpenWriter(filePath string, perm []Permissions) (WriteCloser, error) {
return nil, ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) OpenReadWriter(filePath string, perm []Permissions) (ReadWriteSeekCloser, error) {
return nil, ErrReadOnlyFileSystem
}
func (*ReadOnlyBase) Remove(filePath string) error {
return ErrReadOnlyFileSystem
}