Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions basepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ func (b *BasePathFs) ReadlinkIfPossible(name string) (string, error) {
}
return "", &os.PathError{Op: "readlink", Path: name, Err: ErrNoReadlink}
}

func (b *BasePathFs) ParentFS() Fs {
return b.source
}
4 changes: 4 additions & 0 deletions cacheOnReadFs.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,7 @@ func (u *CacheOnReadFs) Create(name string) (File, error) {
}
return &UnionFile{Base: bfh, Layer: lfh}, nil
}

func (u *CacheOnReadFs) ParentFS() Fs {
return u.base
}
4 changes: 4 additions & 0 deletions readonlyfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ func (r *ReadOnlyFs) MkdirAll(n string, p os.FileMode) error {
func (r *ReadOnlyFs) Create(n string) (File, error) {
return nil, syscall.EPERM
}

func (r *ReadOnlyFs) ParentFS() Fs {
return r.source
}
4 changes: 4 additions & 0 deletions regexpfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (r *RegexpFs) Create(name string) (File, error) {
return r.source.Create(name)
}

func (r *RegexpFs) ParentFS() Fs {
return r.source
}

func (f *RegexpFile) Close() error {
return f.f.Close()
}
Expand Down
24 changes: 24 additions & 0 deletions wrappedfs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © 2018 Steve Francia <[email protected]>.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package afero

// WrappedFs is an optional interface in Afero. It is only implemented by the
// filesystems saying so.
// Filesystems which wrap another filesystem can provide access to their parent
// filesystem by implementing this interface.
// If this interface returns nil, then the filesystem either has no parents or
// is unable to provide a parent.
type WrappedFs interface {
ParentFS() Fs
}