github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libfs/dummy_fs_read_only.go (about) 1 // Copyright 2020 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libfs 6 7 import ( 8 "os" 9 "path" 10 11 "github.com/keybase/client/go/kbfs/libkbfs" 12 "github.com/pkg/errors" 13 billy "gopkg.in/src-d/go-billy.v4" 14 ) 15 16 // dummyFSReadOnly is a wrapper struct that extends a `libkbfs.NodeFSReadOnly` 17 // implementation into a full `billy.Filesystem` (which fails all 18 // write calls to it). 19 type dummyFSReadOnly struct { 20 libkbfs.NodeFSReadOnly 21 } 22 23 var _ billy.Filesystem = dummyFSReadOnly{} 24 25 func (dfsro dummyFSReadOnly) Create(_ string) (billy.File, error) { 26 return nil, errors.New("read-only filesystem") 27 } 28 29 func (dfsro dummyFSReadOnly) Stat(_ string) (os.FileInfo, error) { 30 return nil, errors.New("read-only filesystem") 31 } 32 33 func (dfsro dummyFSReadOnly) Rename(_, _ string) error { 34 return errors.New("read-only filesystem") 35 } 36 37 func (dfsro dummyFSReadOnly) Remove(_ string) error { 38 return errors.New("read-only filesystem") 39 } 40 41 func (dfsro dummyFSReadOnly) Join(p ...string) string { 42 return path.Join(p...) 43 } 44 45 func (dfsro dummyFSReadOnly) TempFile(_, _ string) (billy.File, error) { 46 return nil, errors.New("read-only filesystem") 47 } 48 49 func (dfsro dummyFSReadOnly) MkdirAll(_ string, _ os.FileMode) error { 50 return errors.New("read-only filesystem") 51 } 52 53 func (dfsro dummyFSReadOnly) Symlink(_, _ string) error { 54 return errors.New("read-only filesystem") 55 } 56 57 func (dfsro dummyFSReadOnly) Chroot(_ string) (billy.Filesystem, error) { 58 return nil, errors.New("read-only filesystem") 59 } 60 61 func (dfsro dummyFSReadOnly) Root() string { 62 return "" 63 }