Documentation ¶
Overview ¶
Package fs provides a file system abstraction layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeFakeFS ¶
func MakeFakeFS() *fakeFs
MakeFakeFS returns an instance of fakeFs with no files in it.
Types ¶
type ConfirmedDir ¶
type ConfirmedDir string
ConfirmedDir is a clean, absolute, delinkified path that was confirmed to point to an existing directory.
func NewTmpConfirmedDir ¶
func NewTmpConfirmedDir() (ConfirmedDir, error)
Return a temporary dir, else error. The directory is cleaned, no symlinks, etc. so its returned as a ConfirmedDir.
func (ConfirmedDir) HasPrefix ¶
func (d ConfirmedDir) HasPrefix(path ConfirmedDir) bool
HasPrefix returns true if the directory argument is a prefix of self (d) from the point of view of a file system.
I.e., it's true if the argument equals or contains self (d) in a file path sense.
HasPrefix emulates the semantics of strings.HasPrefix such that the following are true:
strings.HasPrefix("foobar", "foobar") strings.HasPrefix("foobar", "foo") strings.HasPrefix("foobar", "") d := fSys.ConfirmDir("/foo/bar") d.HasPrefix("/foo/bar") d.HasPrefix("/foo") d.HasPrefix("/")
Not contacting a file system here to check for actual path existence.
This is tested on linux, but will have trouble on other operating systems. TODO(monopole) Refactor when #golang/go/18358 closes. See also:
https://github.com/golang/go/issues/18358 https://github.com/golang/dep/issues/296 https://github.com/golang/dep/blob/master/internal/fs/fs.go#L33 https://codereview.appspot.com/5712045
func (ConfirmedDir) Join ¶
func (d ConfirmedDir) Join(path string) string
func (ConfirmedDir) String ¶
func (d ConfirmedDir) String() string
type FakeFile ¶
type FakeFile struct {
// contains filtered or unexported fields
}
FakeFile implements File in-memory for tests.
func (*FakeFile) ContentMatches ¶
ContentMatches returns true if v matches fake file's content.
func (*FakeFile) GetContent ¶
GetContent the content of a fake file.
type Fakefileinfo ¶
type Fakefileinfo struct {
*FakeFile
}
Fakefileinfo implements Fakefileinfo using a fake in-memory filesystem.
func (*Fakefileinfo) IsDir ¶
func (fi *Fakefileinfo) IsDir() bool
IsDir returns if it is a directory
func (*Fakefileinfo) ModTime ¶
func (fi *Fakefileinfo) ModTime() time.Time
ModTime returns the modification time
func (*Fakefileinfo) Sys ¶
func (fi *Fakefileinfo) Sys() interface{}
Sys should return underlying data source, but it now returns nil
type File ¶
type File interface { io.ReadWriteCloser Stat() (os.FileInfo, error) }
File groups the basic os.File methods.
type FileSystem ¶
type FileSystem interface { Create(name string) (File, error) Mkdir(name string) error MkdirAll(name string) error RemoveAll(name string) error Open(name string) (File, error) IsDir(name string) bool CleanedAbs(path string) (ConfirmedDir, string, error) Exists(name string) bool Glob(pattern string) ([]string, error) ReadFile(name string) ([]byte, error) WriteFile(name string, data []byte) error }
FileSystem groups basic os filesystem methods.