From e042b5f805207f2a05fe51c1d12dea7ac75968b4 Mon Sep 17 00:00:00 2001 From: Steve Francia Date: Tue, 8 Dec 2015 15:58:22 -0500 Subject: [PATCH] making the fs property accessible Afero.fs -> Afero.Fs --- afero.go | 2 +- ioutil.go | 10 +++++----- ioutil_test.go | 4 ++-- path.go | 2 +- util.go | 16 ++++++++-------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/afero.go b/afero.go index 9e5fa3c..e3df3f4 100644 --- a/afero.go +++ b/afero.go @@ -30,7 +30,7 @@ import ( ) type Afero struct { - fs Fs + Fs } // File represents a file in the filesystem. diff --git a/ioutil.go b/ioutil.go index 793e5c4..5c3a3d8 100644 --- a/ioutil.go +++ b/ioutil.go @@ -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 == "" { diff --git a/ioutil_test.go b/ioutil_test.go index 894687a..e7c9f06 100644 --- a/ioutil_test.go +++ b/ioutil_test.go @@ -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) diff --git a/path.go b/path.go index 54c5579..1d90e46 100644 --- a/path.go +++ b/path.go @@ -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 { diff --git a/util.go b/util.go index faed9d3..4495496 100644 --- a/util.go +++ b/util.go @@ -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.