diff --git a/basepath.go b/basepath.go index 7fbf223..616ff8f 100644 --- a/basepath.go +++ b/basepath.go @@ -1,7 +1,6 @@ package afero import ( - "errors" "os" "path/filepath" "runtime" @@ -42,7 +41,7 @@ func NewBasePathFs(source Fs, path string) Fs { // else the given file with the base path prepended func (b *BasePathFs) RealPath(name string) (path string, err error) { if err := validateBasePathName(name); err != nil { - return "", err + return name, err } bpath := filepath.Clean(b.path) @@ -64,7 +63,7 @@ func validateBasePathName(name string) error { // On Windows a common mistake would be to provide an absolute OS path // We could strip out the base part, but that would not be very portable. if filepath.IsAbs(name) { - return &os.PathError{Op: "realPath", Path: name, Err: errors.New("got a real OS path instead of a virtual")} + return os.ErrNotExist } return nil diff --git a/basepath_test.go b/basepath_test.go index 219527d..77aa7df 100644 --- a/basepath_test.go +++ b/basepath_test.go @@ -68,8 +68,8 @@ func TestRealPath(t *testing.T) { if runtime.GOOS == "windows" { _, err = bp.RealPath(anotherDir) - if err == nil { - t.Errorf("Expected error") + if err != os.ErrNotExist { + t.Errorf("Expected os.ErrNotExist") } } else {