making the fs property accessible Afero.fs -> Afero.Fs

This commit is contained in:
Steve Francia 2015-12-08 15:58:22 -05:00
parent 2affd36eba
commit 30bd450c02
5 changed files with 17 additions and 17 deletions

View File

@ -30,7 +30,7 @@ import (
)
type Afero struct {
fs Fs
Fs
}
// File represents a file in the filesystem.

View File

@ -36,7 +36,7 @@ func (f byName) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
// ReadDir reads the directory named by dirname and returns
// a list of sorted directory entries.
func (a Afero) ReadDir(dirname string) ([]os.FileInfo, error) {
return ReadDir(a.fs, dirname)
return ReadDir(a.Fs, dirname)
}
func ReadDir(fs Fs, dirname string) ([]os.FileInfo, error) {
@ -58,7 +58,7 @@ func ReadDir(fs Fs, dirname string) ([]os.FileInfo, error) {
// reads the whole file, it does not treat an EOF from Read as an error
// to be reported.
func (a Afero) ReadFile(filename string) ([]byte, error) {
return ReadFile(a.fs, filename)
return ReadFile(a.Fs, filename)
}
func ReadFile(fs Fs, filename string) ([]byte, error) {
@ -118,7 +118,7 @@ func ReadAll(r io.Reader) ([]byte, error) {
// If the file does not exist, WriteFile creates it with permissions perm;
// otherwise WriteFile truncates it before writing.
func (a Afero) WriteFile(filename string, data []byte, perm os.FileMode) error {
return WriteFile(a.fs, filename, data, perm)
return WriteFile(a.Fs, filename, data, perm)
}
func WriteFile(fs Fs, filename string, data []byte, perm os.FileMode) error {
@ -169,7 +169,7 @@ func nextSuffix() string {
// to find the pathname of the file. It is the caller's responsibility
// to remove the file when no longer needed.
func (a Afero) TempFile(dir, prefix string) (f File, err error) {
return TempFile(a.fs, dir, prefix)
return TempFile(a.Fs, dir, prefix)
}
func TempFile(fs Fs, dir, prefix string) (f File, err error) {
@ -202,7 +202,7 @@ func TempFile(fs Fs, dir, prefix string) (f File, err error) {
// will not choose the same directory. It is the caller's responsibility
// to remove the directory when no longer needed.
func (a Afero) TempDir(dir, prefix string) (name string, err error) {
return TempDir(a.fs, dir, prefix)
return TempDir(a.Fs, dir, prefix)
}
func TempDir(fs Fs, dir, prefix string) (name string, err error) {
if dir == "" {

View File

@ -29,7 +29,7 @@ func checkSizePath(t *testing.T, path string, size int64) {
func TestReadFile(t *testing.T) {
testFS = &MemMapFs{}
fsutil := &Afero{fs: testFS}
fsutil := &Afero{Fs: testFS}
testFS.Create("this_exists.go")
filename := "rumpelstilzchen"
@ -49,7 +49,7 @@ func TestReadFile(t *testing.T) {
func TestWriteFile(t *testing.T) {
testFS = &MemMapFs{}
fsutil := &Afero{fs: testFS}
fsutil := &Afero{Fs: testFS}
f, err := fsutil.TempFile("", "ioutil-test")
if err != nil {
t.Fatal(err)

View File

@ -96,7 +96,7 @@ func lstatIfOs(fs Fs, path string) (info os.FileInfo, err error) {
// Walk does not follow symbolic links.
func (a Afero) Walk(root string, walkFn filepath.WalkFunc) error {
return Walk(a.fs, root, walkFn)
return Walk(a.Fs, root, walkFn)
}
func Walk(fs Fs, root string, walkFn filepath.WalkFunc) error {

16
util.go
View File

@ -35,7 +35,7 @@ const FilePathSeparator = string(filepath.Separator)
// Takes a reader and a path and writes the content
func (a Afero) WriteReader(path string, r io.Reader) (err error) {
return WriteReader(a.fs, path, r)
return WriteReader(a.Fs, path, r)
}
func WriteReader(fs Fs, path string, r io.Reader) (err error) {
@ -63,7 +63,7 @@ func WriteReader(fs Fs, path string, r io.Reader) (err error) {
// Same as WriteReader but checks to see if file/directory already exists.
func (a Afero) SafeWriteReader(path string, r io.Reader) (err error) {
return SafeWriteReader(a.fs, path, r)
return SafeWriteReader(a.Fs, path, r)
}
func SafeWriteReader(fs Fs, path string, r io.Reader) (err error) {
@ -96,7 +96,7 @@ func SafeWriteReader(fs Fs, path string, r io.Reader) (err error) {
}
func (a Afero) GetTempDir(subPath string) string {
return GetTempDir(a.fs, subPath)
return GetTempDir(a.Fs, subPath)
}
// GetTempDir returns the default temp directory with trailing slash
@ -170,7 +170,7 @@ func isMn(r rune) bool {
}
func (a Afero) FileContainsBytes(filename string, subslice []byte) (bool, error) {
return FileContainsBytes(a.fs, filename, subslice)
return FileContainsBytes(a.Fs, filename, subslice)
}
// Check if a file contains a specified string.
@ -221,7 +221,7 @@ func readerContains(r io.Reader, subslice []byte) bool {
}
func (a Afero) DirExists(path string) (bool, error) {
return DirExists(a.fs, path)
return DirExists(a.Fs, path)
}
// DirExists checks if a path exists and is a directory.
@ -237,7 +237,7 @@ func DirExists(fs Fs, path string) (bool, error) {
}
func (a Afero) IsDir(path string) (bool, error) {
return IsDir(a.fs, path)
return IsDir(a.Fs, path)
}
// IsDir checks if a given path is a directory.
@ -250,7 +250,7 @@ func IsDir(fs Fs, path string) (bool, error) {
}
func (a Afero) IsEmpty(path string) (bool, error) {
return IsEmpty(a.fs, path)
return IsEmpty(a.Fs, path)
}
// IsEmpty checks if a given file or directory is empty.
@ -275,7 +275,7 @@ func IsEmpty(fs Fs, path string) (bool, error) {
}
func (a Afero) Exists(path string) (bool, error) {
return Exists(a.fs, path)
return Exists(a.Fs, path)
}
// Check if a file or directory exists.