/usr/share/gocode/src/github.com/smartystreets/goconvey/web/server/system/fake_file_system.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | package system
import (
"os"
"path/filepath"
"strings"
"time"
)
type FakeFileSystem struct {
steps []*FakeFileInfo
}
func (self *FakeFileSystem) Create(path string, size int64, modified time.Time) {
self.steps = append(self.steps, newFileInfo(path, size, modified))
}
func (self *FakeFileSystem) Modify(path string) {
for _, step := range self.steps {
if step.path == path {
step.size++
}
}
}
func (self *FakeFileSystem) Rename(original, modified string) {
for _, step := range self.steps {
if step.path == original {
step.path = modified
step.modified = step.modified.Add(time.Second * time.Duration(10))
break
}
}
}
func (self *FakeFileSystem) Delete(path string) {
newSteps := []*FakeFileInfo{}
for _, step := range self.steps {
if !strings.HasPrefix(step.path, path) {
newSteps = append(newSteps, step)
}
}
self.steps = newSteps
}
func (self *FakeFileSystem) Walk(root string, step filepath.WalkFunc) {
for _, info := range self.steps {
if strings.HasPrefix(info.path, root) {
step(info.path, info, nil)
}
}
}
func (self *FakeFileSystem) Listing(directory string) ([]os.FileInfo, error) {
var entries []os.FileInfo
for _, info := range self.steps {
if strings.HasPrefix(info.path, directory) && info.path != directory {
entries = append(entries, info)
}
}
return entries, nil
}
func (self *FakeFileSystem) Exists(directory string) bool {
for _, info := range self.steps {
if info.IsDir() && info.path == directory {
return true
}
}
return false
}
func NewFakeFileSystem() *FakeFileSystem {
self := &FakeFileSystem{}
self.steps = []*FakeFileInfo{}
return self
}
type FakeFileInfo struct {
path string
size int64
modified time.Time
}
func (self *FakeFileInfo) Name() string { return filepath.Base(self.path) }
func (self *FakeFileInfo) Size() int64 { return self.size }
func (self *FakeFileInfo) Mode() os.FileMode { return 0 }
func (self *FakeFileInfo) ModTime() time.Time { return self.modified }
func (self *FakeFileInfo) IsDir() bool { return filepath.Ext(self.path) == "" }
func (self *FakeFileInfo) Sys() interface{} { return nil }
func newFileInfo(path string, size int64, modified time.Time) *FakeFileInfo {
self := &FakeFileInfo{}
self.path = path
self.size = size
self.modified = modified
return self
}
|